Skip to content

Commit

Permalink
Merge branch 'main' into protometh
Browse files Browse the repository at this point in the history
  • Loading branch information
JelleZijlstra authored Oct 17, 2024
2 parents 06e5370 + 06a2682 commit 6dfb7e1
Show file tree
Hide file tree
Showing 28 changed files with 907 additions and 421 deletions.
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#
# flake8-bugbear rules that cause too many false positives:
# B905 "`zip()` without an explicit `strict=True` parameter --
# the `strict` parameter was introduced in Python 3.10; we support Python 3.8
# the `strict` parameter was introduced in Python 3.10; we support Python 3.9
# B907 "Use !r inside f-strings instead of manual quotes" --
# produces false positives if you're surrounding things with double quotes

Expand Down
35 changes: 13 additions & 22 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,33 +29,27 @@ jobs:
timeout-minutes: 5
strategy:
matrix:
python-version: ["3.8", "3.12"]
python-version: ["3.9", "3.13"]
fail-fast: false
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- uses: astral-sh/setup-uv@v1
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: pyproject.toml
allow-prereleases: true
- run: pip install -e .[dev]
- run: mypy
version: "latest"
- run: |
uv run --python=3.12 --extra=dev mypy --python-version=${{ matrix.python-version }}
flake8:
name: flake8
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- uses: astral-sh/setup-uv@v1
with:
python-version: "3.11"
cache: pip
cache-dependency-path: pyproject.toml
- run: pip install -e .[dev]
version: "latest"
- run: |
flake8 $(git ls-files | grep 'py$') --color always
uv run --python=3.12 --extra=dev flake8 $(git ls-files | grep 'py$') --color=always
tests:
name: pytest suite
Expand All @@ -64,15 +58,12 @@ jobs:
strategy:
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
fail-fast: false
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- uses: astral-sh/setup-uv@v1
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
cache: pip
cache-dependency-path: pyproject.toml
- run: pip install -e .[dev]
- run: python3 -m pytest -vv
version: "latest"
- run: |
uv run --python=${{ matrix.python-version }} --extra=dev pytest -vv
6 changes: 3 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ jobs:
id-token: write
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.10"
python-version: "3.12"
- name: Install pypa/build
run: >-
python -m
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/typeshed_primer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,31 +37,31 @@ jobs:
repository: python/typeshed
path: typeshed
- name: Setup Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: pip
cache-dependency-path: new_plugin/pyproject.toml
- run: pip install flake8-noqa
python-version: "3.12"
- name: Install uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- run: uv pip install flake8-noqa --system
# We cd so that "old_plugin"/"new_plugin"/typeshed" don't appear in the error path
- name: flake8 typeshed using target branch
run: |
cd old_plugin
pip install -e .
uv pip install -e . --system
cd ../typeshed
flake8 --exit-zero --color never --output-file ../old_errors.txt
- name: flake8 typeshed using PR branch
run: |
cd new_plugin
pip install -e .
uv pip install -e . --system --reinstall
cd ../typeshed
flake8 --exit-zero --color never --output-file ../new_errors.txt
- name: Get diff between the two runs
run: |
echo ${{ github.event.pull_request.number }} | tee pr_number.txt
diff old_errors.txt new_errors.txt | tee errors_diff.txt
- name: Upload diff and PR number
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: typeshed_primer_errors
path: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/typeshed_primer_comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Download errors
uses: actions/github-script@v6
uses: actions/github-script@v7
with:
script: await require('.github/scripts/typeshed_primer_download_errors.js')({github, context})
- run: unzip errors.zip
- name: Post comment
id: post-comment
uses: actions/github-script@v6
uses: actions/github-script@v7
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: return await require('.github/scripts/typeshed_primer_post_comment.js')({github, context})
Expand Down
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0 # must match pyproject.toml
rev: v4.6.0 # must match pyproject.toml
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand All @@ -9,12 +9,12 @@ repos:
- id: check-merge-conflict
- id: mixed-line-ending
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.9.1 # must match pyproject.toml
rev: 24.8.0 # must match pyproject.toml
hooks:
- id: black
language_version: python3.8
language_version: python3.9
- repo: https://github.com/pycqa/isort
rev: 5.12.0 # must match pyproject.toml
rev: 5.13.2 # must match pyproject.toml
hooks:
- id: isort
name: isort (python)
Expand Down
83 changes: 78 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,87 @@
# Change Log

## Unreleased
## 24.9.0

Bugfixes
* Don't emit Y053 for long strings inside `Literal` slices or
metadata strings inside `Annotated` slices.

Other changes:
* `flake8-pyi` no longer supports being run using Python 3.8.
As a result, it not longer depends on the third-party
`ast_decompiler` package.

## 24.6.0

Bugfixes
* Allow the use of `typing_extensions.TypeVar` in stubs.
`typing_extensions.TypeVar` has the *default* parameter,
which only exists on Python 3.13+ when using `typing.TypeVar`.
* Reduce false positives from Y052 in relation to enum subclasses.

Other changes
* Declare support for Python 3.13

## 24.4.1

New error codes:
* Y066: When using if/else with `sys.version_info`,
put the code for new Python versions first.

## 24.4.0

Bugfixes:
* Fix Y026 false positive: allow simple assignment to `None` in class scopes
if the class is known to be an enum class.

## 24.3.1

New error codes:
* Y064: Use simpler syntax to define final literal types.
For example, use `x: Final = 42` instead of `x: Final[Literal[42]]`
* Y065: Don't use bare `Incomplete` in parameter and return annotations.

Bugfixes:
* Y090: Fix false positive for `tuple[Unpack[Ts]]`.

## 24.3.0

New error codes:
* Y063: Use [PEP 570 syntax](https://peps.python.org/pep-0570/) to mark
positional-only arguments, rather than
[the older Python 3.7-compatible syntax](https://peps.python.org/pep-0484/#positional-only-arguments)
described in PEP 484.

## 24.1.0

New error codes:
* Y062: Disallow duplicate elements inside `Literal[]` slices.

Other features:
* Support flake8>=7.0.0
* Y061 is no longer emitted in situations where Y062 would also be emitted.
* Improve error message for Y060.
* Y023 now bans more imports from `typing_extensions` now that typeshed has
dropped support for Python 3.7.

Bugfixes:
* Y016: Fix false positive if a method had positional-only parameters (using
[PEP 570 syntax](https://peps.python.org/pep-0570/) and the first
positional-or-keyword parameter following the positional-only parameters used
a custom TypeVar (see #455).
* Y046: Fix false negative where an unused protocol would not be detected if
the protocol was generic.

## 23.11.0

New error codes:
* Introduce Y058: Use `Iterator` rather than `Generator` as the return value
* Y058: Use `Iterator` rather than `Generator` as the return value
for simple `__iter__` methods, and `AsyncIterator` rather than
`AsyncGenerator` as the return value for simple `__aiter__` methods.
* Introduce Y059: `Generic[]` should always be the last base class, if it is
* Y059: `Generic[]` should always be the last base class, if it is
present in the bases of a class.
* Introduce Y060, which flags redundant inheritance from `Generic[]`.
* Introduce Y061: Do not use `None` inside a `Literal[]` slice.
* Y060, which flags redundant inheritance from `Generic[]`.
* Y061: Do not use `None` inside a `Literal[]` slice.
For example, use `Literal["foo"] | None` instead of `Literal["foo", None]`.
* Introduce Y062: Protocol method parameters should not be positional-or-keyword.

Expand All @@ -30,6 +102,7 @@ Other changes:
reduce the number of false positives from this check.
* Attempting to import `typing_extensions.Text` now causes Y039 to be emitted
rather than Y023.
* Y053 will no longer be emitted for the argument to `@typing_extensions.deprecated`.

## 23.10.0

Expand Down
Loading

0 comments on commit 6dfb7e1

Please sign in to comment.