Skip to content

Commit

Permalink
Merge branch 'main' into fix/fix_deprecated_link
Browse files Browse the repository at this point in the history
  • Loading branch information
staticdev authored Jan 20, 2025
2 parents 26193e7 + bced410 commit 178fb00
Show file tree
Hide file tree
Showing 72 changed files with 933 additions and 835 deletions.
5 changes: 2 additions & 3 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
[flake8]
max-line-length = 100
# Ignore non PEP 8 compliant rules as suggested by black
# E203: /~https://github.com/psf/black/blob/3fab5ade71bccf80ae0a5af76729099869adea56/docs/the_black_code_style/current_style.md#slices
extend-ignore =
E203, # /~https://github.com/psf/black/blob/master/docs/the_black_code_style.md#slices
E203,
E501,
B017
exclude = _vendored
per-file-ignores =
isort/__init__.py:F401
isort/stdlibs/__init__.py:F401
tests/unit/example_crlf_file.py:F401
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
groups:
github-actions:
patterns:
- "*"
2 changes: 1 addition & 1 deletion .github/workflows/constraints.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pip==22.3.1
pip==23.2
virtualenv==20.17.1
15 changes: 4 additions & 11 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,16 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11"]
python-version: ["3.12"]

steps:
- uses: actions/checkout@v2

- name: pip cache
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: integration-pip-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
integration-pip-
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"

- name: Upgrade pip
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Run Labeler
uses: crazy-max/ghaction-github-labeler@v4
uses: crazy-max/ghaction-github-labeler@v5
with:
skip-delete: true
15 changes: 4 additions & 11 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,16 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11"]
python-version: ["3.12"]

steps:
- uses: actions/checkout@v2

- name: pip cache
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: lint-pip-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
lint-pip-
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"

- name: Upgrade pip
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/poetry-constraints.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
poetry==1.3.1
poetry==1.8.5
2 changes: 1 addition & 1 deletion .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ jobs:
if: github.repository_owner == 'PyCQA'
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v5
- uses: release-drafter/release-drafter@v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 2

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.11"
python-version: "3.12"

- name: Upgrade pip
run: |
Expand Down Expand Up @@ -65,7 +65,7 @@ jobs:
password: ${{ secrets.PYPI_API_TOKEN }}

- name: Publish the release notes
uses: release-drafter/release-drafter@v5
uses: release-drafter/release-drafter@v6
with:
publish: ${{ steps.check-version.outputs.tag != '' }}
tag: ${{ steps.check-version.outputs.tag }}
Expand Down
40 changes: 6 additions & 34 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,45 +17,17 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
os: [ubuntu-latest, macos-latest, windows-latest]

steps:
- uses: actions/checkout@v2
- name: Ubuntu cache
uses: actions/cache@v2
if: startsWith(matrix.os, 'ubuntu')
with:
path: ~/.cache/pip
key:
${{ matrix.os }}-${{ matrix.python-version }}-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
${{ matrix.os }}-${{ matrix.python-version }}-
- name: macOS cache
uses: actions/cache@v2
if: startsWith(matrix.os, 'macOS')
with:
path: ~/Library/Caches/pip
key:
${{ matrix.os }}-${{ matrix.python-version }}-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
${{ matrix.os }}-${{ matrix.python-version }}-
- name: Windows cache
uses: actions/cache@v2
if: startsWith(matrix.os, 'windows')
with:
path: c:\users\runneradmin\appdata\local\pip\cache
key:
${{ matrix.os }}-${{ matrix.python-version }}-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
${{ matrix.os }}-${{ matrix.python-version }}-
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"

- name: Upgrade pip
run: |
Expand All @@ -64,7 +36,7 @@ jobs:
- name: Install Poetry
run: |
pipx install --pip-args=--constraint=.github/workflows/poetry-constraints.txt poetry
pip install --constraint=.github/workflows/poetry-constraints.txt poetry
poetry --version
- name: Install dependencies
Expand All @@ -76,4 +48,4 @@ jobs:

- name: Report Coverage
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v5
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
repos:
- repo: /~https://github.com/pycqa/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort
4 changes: 2 additions & 2 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
- id: isort
name: isort
entry: isort
stages: [commit, merge-commit, push, manual]
stages: [pre-commit, pre-merge-commit, pre-push, manual]
require_serial: true
language: python
types_or: [cython, pyi, python]
args: ['--filter-files']
minimum_pre_commit_version: '2.9.2'
minimum_pre_commit_version: '3.2.0'
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
------------------------------------------------------------------------

[![PyPI version](https://badge.fury.io/py/isort.svg)](https://badge.fury.io/py/isort)
[![Test Status](/~https://github.com/pycqa/isort/workflows/Test/badge.svg?branch=develop)](/~https://github.com/pycqa/isort/actions?query=workflow%3ATest)
[![Lint Status](/~https://github.com/pycqa/isort/workflows/Lint/badge.svg?branch=develop)](/~https://github.com/pycqa/isort/actions?query=workflow%3ALint)
[![Test](/~https://github.com/PyCQA/isort/actions/workflows/test.yml/badge.svg)](/~https://github.com/PyCQA/isort/actions/workflows/test.yml)
[![Lint](/~https://github.com/PyCQA/isort/actions/workflows/lint.yml/badge.svg)](/~https://github.com/PyCQA/isort/actions/workflows/lint.yml)
[![Code coverage Status](https://codecov.io/gh/pycqa/isort/branch/main/graph/badge.svg)](https://codecov.io/gh/pycqa/isort)
[![License](https://img.shields.io/github/license/mashape/apistatus.svg)](https://pypi.org/project/isort/)
[![Join the chat at https://gitter.im/timothycrosley/isort](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/timothycrosley/isort?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
Expand All @@ -23,7 +23,7 @@ isort is a Python utility / library to sort imports alphabetically and
automatically separate into sections and by type. It provides a command line
utility, Python library and [plugins for various
editors](/~https://github.com/pycqa/isort/wiki/isort-Plugins) to
quickly sort all your imports. It requires Python 3.8+ to run but
quickly sort all your imports. It requires Python 3.9+ to run but
supports formatting Python 2 code too.

- [Try isort now from your browser!](https://pycqa.github.io/isort/docs/quick_start/0.-try.html)
Expand Down
5 changes: 2 additions & 3 deletions docs/configuration/black_compatibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ language: python
python:
- "3.10"
- "3.9"
- "3.8"

install:
- pip install -r requirements-dev.txt
Expand All @@ -56,8 +55,8 @@ See [built-in profiles](https://pycqa.github.io/isort/docs/configuration/profile
You can also set the profile directly when integrating isort within pre-commit.

```yaml
- repo: /~https://github.com/pycqa/isort
rev: 5.11.5
- repo: /~https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
args: ["--profile", "black", "--filter-files"]
Expand Down
14 changes: 7 additions & 7 deletions docs/configuration/github_action.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ By default, it will run recursively from the root of the repository being linted

### Inputs

#### `isortVersion`
#### `isort-version`

Optional. Version of `isort` to use. Defaults to latest version of `isort`.

#### `sortPaths`
#### `sort-paths`

Optional. List of paths to sort, relative to your project root. Defaults to `.`

#### `configuration`

Optional. `isort` configuration options to pass to the `isort` CLI. Defaults to `--check-only --diff`.

#### `requirementsFiles`
#### `requirements-files`

Optional. Paths to python requirements files to install before running isort.
If multiple requirements files are provided, they should be separated by a space.
Expand All @@ -48,11 +48,11 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.8
- uses: isort/isort-action@master
python-version: 3.13
- uses: isort/isort-action@v1
with:
requirementsFiles: "requirements.txt requirements-test.txt"
```
Expand Down
1 change: 1 addition & 0 deletions docs/configuration/profiles.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ To use any of the listed profiles, use `isort --profile PROFILE_NAME` from the c

- **multi_line_output**: `3`
- **include_trailing_comma**: `True`
- **split_on_trailing_comma**: `True`
- **force_grid_wrap**: `0`
- **use_parentheses**: `True`
- **ensure_newline_before_comments**: `True`
Expand Down
2 changes: 1 addition & 1 deletion docs/contributing/1.-contributing-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Account Requirements:

Base System Requirements:

- Python3.8+
- Python3.9+
- poetry
- bash or a bash compatible shell (should be auto-installed on Linux / Mac)
- WSL users running Ubuntu may need to install Python's venv module even after installing Python.
Expand Down
2 changes: 1 addition & 1 deletion docs/major_releases/introducing_isort_5.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ import c
import d
```

isort 5 adds support for [Action Comments](https://pycqa.github.io/isort/docs/configuration/action_comments.html) which provide a quick and convient way to control the flow of parsing within single source files.
isort 5 adds support for [Action Comments](https://pycqa.github.io/isort/docs/configuration/action_comments.html) which provide a quick and convenient way to control the flow of parsing within single source files.


# First class Python API
Expand Down
2 changes: 1 addition & 1 deletion docs/quick_start/0.-try.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Use our live isort editor to see how isort can help improve the formatting of yo
window.languagePluginUrl = 'https://cdn.jsdelivr.net/pyodide/v0.15.0/full/';
</script>
<script src="https://cdn.jsdelivr.net/pyodide/v0.15.0/full/pyodide.js" integrity="sha256-W+0Mr+EvJb1qJx9UZ9wuvd/uWrXCzeaEu6OzEEHMCik=" crossorigin="anonymous"></script>
<script src="https://pagecdn.io/lib/ace/1.4.5/ace.js" integrity="sha256-5Xkhn3k/1rbXB+Q/DX/2RuAtaB4dRRyQvMs83prFjpM=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/ace-builds@1.4.5/src-min-noconflict/ace.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://pycqa.github.io/isort/docs/quick_start/interactive.css">
</head>

Expand Down
2 changes: 1 addition & 1 deletion docs/quick_start/1.-install.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ For a fully isolated user installation you can use [pipx](/~https://github.com/pip
<script id="asciicast-qZglwdh3YdoRHjtpxuNmQJehj" src="https://asciinema.org/a/qZglwdh3YdoRHjtpxuNmQJehj.js" async></script>

!!!tip
If you want isort to act as a linter for projects, it probably makes since to add isort as an explicit development dependency for each project that uses it. If, on the other hand, you are an individual developer simply using isort as a personal tool to clean up your own commits, a global or user level installation makes sense. Both are seamlessly supported on a single machine.
If you want isort to act as a linter for projects, it probably makes sense to add isort as an explicit development dependency for each project that uses it. If, on the other hand, you are an individual developer simply using isort as a personal tool to clean up your own commits, a global or user level installation makes sense. Both are seamlessly supported on a single machine.
2 changes: 1 addition & 1 deletion docs/upgrade_guides/5.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ isort now includes an optimized precommit configuration in the repo itself. To u

```
- repo: /~https://github.com/pycqa/isort
rev: 5.8.0
rev: 5.13.2
hooks:
- id: isort
name: isort (python)
Expand Down
1 change: 1 addition & 0 deletions isort/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Defines the public isort interface"""

__all__ = (
"Config",
"ImportKey",
Expand Down
18 changes: 9 additions & 9 deletions isort/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,9 @@ def _file_output_stream_context(filename: Union[str, Path], source_file: File) -
yield output_stream


# Ignore DeepSource cyclomatic complexity check for this function. It is one
# the main entrypoints so sort of expected to be complex.
# skipcq: PY-R1000
def sort_file(
filename: Union[str, Path],
extension: Optional[str] = None,
Expand Down Expand Up @@ -442,9 +445,9 @@ def sort_file(
file_input=source_file.stream.read(),
file_output=output_stream.read(),
file_path=actual_file_path,
output=None
if show_diff is True
else cast(TextIO, show_diff),
output=(
None if show_diff is True else cast(TextIO, show_diff)
),
color_output=config.color_output,
)
if show_diff or (
Expand All @@ -466,12 +469,9 @@ def sort_file(
if not config.quiet:
print(f"Fixing {source_file.path}")
finally:
try: # Python 3.8+: use `missing_ok=True` instead of try except.
if not config.overwrite_in_place: # pragma: no branch
tmp_file = _tmp_file(source_file)
tmp_file.unlink()
except FileNotFoundError:
pass # pragma: no cover
if not config.overwrite_in_place: # pragma: no branch
tmp_file = _tmp_file(source_file)
tmp_file.unlink(missing_ok=True)
else:
changed = sort_stream(
input_stream=source_file.stream,
Expand Down
Loading

0 comments on commit 178fb00

Please sign in to comment.