Skip to content

Commit cc206f7

Browse files
authored
Drop flake8-noqa and remove workarounds to work with Ruff (#13571)
1 parent 96c3fe7 commit cc206f7

File tree

9 files changed

+14
-26
lines changed

9 files changed

+14
-26
lines changed

.flake8

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
[flake8]
2-
# NQA: Ruff won't warn about redundant `# noqa: Y`
32
# Y: Flake8 is only used to run flake8-pyi, everything else is in Ruff
43
# F821: Typeshed is a testing ground for flake8-pyi, which monkeypatches F821
5-
select = NQA, Y, F821
4+
select = Y, F821
65
# Ignore rules normally excluded by default
76
extend-ignore = Y090
87
per-file-ignores =
9-
# We should only need to noqa Y and F821 codes in .pyi files
10-
*.py: NQA
118
# Generated protobuf files:
129
# Y021: Include docstrings
1310
# Y023: Alias typing as typing_extensions
@@ -16,4 +13,3 @@ per-file-ignores =
1613
stubs/*_pb2.pyi: Y021, Y023, Y026, Y053
1714

1815
exclude = .venv*,.git
19-
noqa_require_code = true

.pre-commit-config.yaml

+1-2
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,11 @@ repos:
3131
hooks:
3232
- id: black
3333
- repo: https://github.com/pycqa/flake8
34-
rev: 7.1.1
34+
rev: 7.1.2
3535
hooks:
3636
- id: flake8
3737
language: python
3838
additional_dependencies:
39-
- "flake8-noqa==1.4.0"
4039
- "flake8-pyi==24.9.0"
4140
types: [file]
4241
types_or: [python, pyi]

CONTRIBUTING.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ it takes a bit longer. For more details, read below.
2828

2929
Typeshed runs continuous integration (CI) on all pull requests. This means that
3030
if you file a pull request (PR), our full test suite
31-
-- including our linter, [Flake8](https://github.com/PyCQA/flake8) --
31+
-- including our linter, [`flake8-pyi`](https://github.com/pycqa/flake8-pyi) --
3232
is run on your PR. It also means that bots will automatically apply
3333
changes to your PR (using [Black](https://github.com/psf/black) and
3434
[Ruff](https://github.com/astral-sh/ruff)) to fix any formatting issues.
@@ -88,8 +88,7 @@ The code is formatted using [`Black`](https://github.com/psf/black).
8888
Various other autofixes and lint rules are
8989
also performed by [`Ruff`](https://github.com/astral-sh/ruff) and
9090
[`Flake8`](https://github.com/pycqa/flake8),
91-
with plugins [`flake8-pyi`](https://github.com/pycqa/flake8-pyi),
92-
and [`flake8-noqa`](https://github.com/plinss/flake8-noqa).
91+
with plugin [`flake8-pyi`](https://github.com/pycqa/flake8-pyi).
9392

9493
The repository is equipped with a [pre-commit.ci](https://pre-commit.ci/)
9594
configuration file. This means that you don't *need* to do anything yourself to

pyproject.toml

+3-5
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ exclude = [
3333
# are invoked via separate runs of ruff in pre-commit:
3434
# see our .pre-commit-config.yaml file for details
3535
exclude = ["**/test_cases/**/*.py"]
36-
# We still use flake8-pyi and flake8-noqa to check these (see .flake8 config file);
36+
# We still use flake8-pyi to check these (see .flake8 config file);
3737
# tell ruff not to flag these as e.g. "unused noqa comments"
38-
external = ["F821", "NQA", "Y"]
38+
external = ["F821", "Y"]
3939
select = [
4040
"ARG", # flake8-unused-arguments
4141
"B", # flake8-bugbear
@@ -67,8 +67,7 @@ select = [
6767
"FURB177", # Prefer `Path.cwd()` over `Path().resolve()` for current-directory lookups
6868
"FURB187", # Use of assignment of `reversed` on list `{name}`
6969
# PYI: only enable rules that have autofixes and that we always want to fix (even manually),
70-
# avoids duplicate # noqa with flake8-pyi and flake8-noqa flagging `PYI` codes
71-
# See https://github.com/plinss/flake8-noqa/issues/22
70+
# avoids duplicate # noqa with flake8-pyi
7271
"PYI009", # Empty body should contain `...`, not pass
7372
"PYI010", # Function body must contain only `...`
7473
"PYI012", # Class bodies must not contain `pass`
@@ -82,7 +81,6 @@ select = [
8281
# "PYI026", Waiting for this mypy bug to be fixed: https://github.com/python/mypy/issues/16581
8382
"PYI030", # Multiple literal members in a union. Use a single literal, e.g. `Literal[{}]`
8483
"PYI032", # Prefer `object` to `Any` for the second parameter to `{method_name}`
85-
"PYI034", # `__new__` methods usually return self at runtime
8684
"PYI036", # Star-args in `{method_name}` should be annotated with `object`
8785
"PYI044", # `from __future__ import annotations` has no effect in stub files, since type checkers automatically treat stubs as having those semantics
8886
"PYI055", # Multiple `type[T]` usages in a union. Combine them into one, e.g., `type[{union_str}]`.

stdlib/builtins.pyi

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# ruff: noqa: PYI036 # This is the module declaring BaseException
21
import _ast
32
import _sitebuiltins
43
import _typeshed
@@ -870,7 +869,11 @@ class memoryview(Sequence[_I]):
870869
def __new__(cls, obj: ReadableBuffer) -> Self: ...
871870
def __enter__(self) -> Self: ...
872871
def __exit__(
873-
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None, /
872+
self,
873+
exc_type: type[BaseException] | None, # noqa: PYI036 # This is the module declaring BaseException
874+
exc_val: BaseException | None,
875+
exc_tb: TracebackType | None,
876+
/,
874877
) -> None: ...
875878
@overload
876879
def cast(self, format: Literal["c", "@c"], shape: list[int] | tuple[int, ...] = ...) -> memoryview[bytes]: ...

stdlib/typing_extensions.pyi

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# Since this module defines "Self" it is not recognized by Ruff as typing_extensions.Self
2-
# ruff: noqa: PYI034
31
import abc
42
import sys
53
import typing
@@ -251,6 +249,7 @@ class _TypedDict(Mapping[str, object], metaclass=abc.ABCMeta):
251249
@overload
252250
def __ror__(self, value: dict[str, Any], /) -> dict[str, object]: ...
253251
# supposedly incompatible definitions of `__ior__` and `__or__`:
252+
# Since this module defines "Self" it is not recognized by Ruff as typing_extensions.Self
254253
def __ior__(self, value: Self, /) -> Self: ... # type: ignore[misc]
255254

256255
OrderedDict = _Alias()

stubs/boltons/boltons/dictutils.pyi

+1-3
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,7 @@ class FrozenDict(dict[_KT, _VT]):
9191
@classmethod
9292
def fromkeys(cls, keys: Iterable[_KT], value: _VT | None = None) -> Self: ... # type: ignore[override]
9393
def updated(self, *a, **kw) -> Self: ...
94-
# Can't noqa because of https://github.com/plinss/flake8-noqa/pull/30
95-
# Signature conflicts with superclass, so let's just omit it
96-
# def __ior__(self, *a, **kw) -> NoReturn: ...
94+
def __ior__(self, *a, **kw) -> NoReturn: ... # type: ignore[misc] # noqa: Y034 # Signature conflicts with superclass
9795
def __setitem__(self, *a, **kw) -> NoReturn: ...
9896
def __delitem__(self, *a, **kw) -> NoReturn: ...
9997
def update(self, *a, **kw) -> NoReturn: ...

stubs/geopandas/geopandas/io/sql.pyi

-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ from pandas._typing import Scalar
1010
from ..base import _ConvertibleToCRS
1111
from ..geodataframe import GeoDataFrame
1212

13-
# inline ruff noqa at _SqlalchemyConnectionLike.__enter__ confuses flake8
14-
# ruff: noqa: PYI034
15-
1613
# Start SQLAlchemy hack
1714
# ---------------------
1815
# The code actually explicitly checks for SQLAlchemy's `Connection` and `Engine` with

stubs/six/six/moves/builtins.pyi

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# flake8: noqa: NQA102 # https://github.com/plinss/flake8-noqa/issues/22
21
# six explicitly re-exports builtins. Normally this is something we'd want to avoid.
32
# But this is specifically a compatibility package.
43
from builtins import * # noqa: UP029

0 commit comments

Comments
 (0)