mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-05-07 14:00:12 +08:00
Drop flake8-noqa and remove workarounds to work with Ruff (#13571)
This commit is contained in:
@@ -1,13 +1,10 @@
|
||||
[flake8]
|
||||
# NQA: Ruff won't warn about redundant `# noqa: Y`
|
||||
# Y: Flake8 is only used to run flake8-pyi, everything else is in Ruff
|
||||
# F821: Typeshed is a testing ground for flake8-pyi, which monkeypatches F821
|
||||
select = NQA, Y, F821
|
||||
select = Y, F821
|
||||
# Ignore rules normally excluded by default
|
||||
extend-ignore = Y090
|
||||
per-file-ignores =
|
||||
# We should only need to noqa Y and F821 codes in .pyi files
|
||||
*.py: NQA
|
||||
# Generated protobuf files:
|
||||
# Y021: Include docstrings
|
||||
# Y023: Alias typing as typing_extensions
|
||||
@@ -16,4 +13,3 @@ per-file-ignores =
|
||||
stubs/*_pb2.pyi: Y021, Y023, Y026, Y053
|
||||
|
||||
exclude = .venv*,.git
|
||||
noqa_require_code = true
|
||||
|
||||
@@ -31,12 +31,11 @@ repos:
|
||||
hooks:
|
||||
- id: black
|
||||
- repo: https://github.com/pycqa/flake8
|
||||
rev: 7.1.1
|
||||
rev: 7.1.2
|
||||
hooks:
|
||||
- id: flake8
|
||||
language: python
|
||||
additional_dependencies:
|
||||
- "flake8-noqa==1.4.0"
|
||||
- "flake8-pyi==24.9.0"
|
||||
types: [file]
|
||||
types_or: [python, pyi]
|
||||
|
||||
+2
-3
@@ -28,7 +28,7 @@ it takes a bit longer. For more details, read below.
|
||||
|
||||
Typeshed runs continuous integration (CI) on all pull requests. This means that
|
||||
if you file a pull request (PR), our full test suite
|
||||
-- including our linter, [Flake8](https://github.com/PyCQA/flake8) --
|
||||
-- including our linter, [`flake8-pyi`](https://github.com/pycqa/flake8-pyi) --
|
||||
is run on your PR. It also means that bots will automatically apply
|
||||
changes to your PR (using [Black](https://github.com/psf/black) and
|
||||
[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).
|
||||
Various other autofixes and lint rules are
|
||||
also performed by [`Ruff`](https://github.com/astral-sh/ruff) and
|
||||
[`Flake8`](https://github.com/pycqa/flake8),
|
||||
with plugins [`flake8-pyi`](https://github.com/pycqa/flake8-pyi),
|
||||
and [`flake8-noqa`](https://github.com/plinss/flake8-noqa).
|
||||
with plugin [`flake8-pyi`](https://github.com/pycqa/flake8-pyi).
|
||||
|
||||
The repository is equipped with a [pre-commit.ci](https://pre-commit.ci/)
|
||||
configuration file. This means that you don't *need* to do anything yourself to
|
||||
|
||||
+3
-5
@@ -33,9 +33,9 @@ exclude = [
|
||||
# are invoked via separate runs of ruff in pre-commit:
|
||||
# see our .pre-commit-config.yaml file for details
|
||||
exclude = ["**/test_cases/**/*.py"]
|
||||
# We still use flake8-pyi and flake8-noqa to check these (see .flake8 config file);
|
||||
# We still use flake8-pyi to check these (see .flake8 config file);
|
||||
# tell ruff not to flag these as e.g. "unused noqa comments"
|
||||
external = ["F821", "NQA", "Y"]
|
||||
external = ["F821", "Y"]
|
||||
select = [
|
||||
"ARG", # flake8-unused-arguments
|
||||
"B", # flake8-bugbear
|
||||
@@ -67,8 +67,7 @@ select = [
|
||||
"FURB177", # Prefer `Path.cwd()` over `Path().resolve()` for current-directory lookups
|
||||
"FURB187", # Use of assignment of `reversed` on list `{name}`
|
||||
# PYI: only enable rules that have autofixes and that we always want to fix (even manually),
|
||||
# avoids duplicate # noqa with flake8-pyi and flake8-noqa flagging `PYI` codes
|
||||
# See https://github.com/plinss/flake8-noqa/issues/22
|
||||
# avoids duplicate # noqa with flake8-pyi
|
||||
"PYI009", # Empty body should contain `...`, not pass
|
||||
"PYI010", # Function body must contain only `...`
|
||||
"PYI012", # Class bodies must not contain `pass`
|
||||
@@ -82,7 +81,6 @@ select = [
|
||||
# "PYI026", Waiting for this mypy bug to be fixed: https://github.com/python/mypy/issues/16581
|
||||
"PYI030", # Multiple literal members in a union. Use a single literal, e.g. `Literal[{}]`
|
||||
"PYI032", # Prefer `object` to `Any` for the second parameter to `{method_name}`
|
||||
"PYI034", # `__new__` methods usually return self at runtime
|
||||
"PYI036", # Star-args in `{method_name}` should be annotated with `object`
|
||||
"PYI044", # `from __future__ import annotations` has no effect in stub files, since type checkers automatically treat stubs as having those semantics
|
||||
"PYI055", # Multiple `type[T]` usages in a union. Combine them into one, e.g., `type[{union_str}]`.
|
||||
|
||||
+5
-2
@@ -1,4 +1,3 @@
|
||||
# ruff: noqa: PYI036 # This is the module declaring BaseException
|
||||
import _ast
|
||||
import _sitebuiltins
|
||||
import _typeshed
|
||||
@@ -870,7 +869,11 @@ class memoryview(Sequence[_I]):
|
||||
def __new__(cls, obj: ReadableBuffer) -> Self: ...
|
||||
def __enter__(self) -> Self: ...
|
||||
def __exit__(
|
||||
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None, /
|
||||
self,
|
||||
exc_type: type[BaseException] | None, # noqa: PYI036 # This is the module declaring BaseException
|
||||
exc_val: BaseException | None,
|
||||
exc_tb: TracebackType | None,
|
||||
/,
|
||||
) -> None: ...
|
||||
@overload
|
||||
def cast(self, format: Literal["c", "@c"], shape: list[int] | tuple[int, ...] = ...) -> memoryview[bytes]: ...
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
# Since this module defines "Self" it is not recognized by Ruff as typing_extensions.Self
|
||||
# ruff: noqa: PYI034
|
||||
import abc
|
||||
import sys
|
||||
import typing
|
||||
@@ -251,6 +249,7 @@ class _TypedDict(Mapping[str, object], metaclass=abc.ABCMeta):
|
||||
@overload
|
||||
def __ror__(self, value: dict[str, Any], /) -> dict[str, object]: ...
|
||||
# supposedly incompatible definitions of `__ior__` and `__or__`:
|
||||
# Since this module defines "Self" it is not recognized by Ruff as typing_extensions.Self
|
||||
def __ior__(self, value: Self, /) -> Self: ... # type: ignore[misc]
|
||||
|
||||
OrderedDict = _Alias()
|
||||
|
||||
@@ -91,9 +91,7 @@ class FrozenDict(dict[_KT, _VT]):
|
||||
@classmethod
|
||||
def fromkeys(cls, keys: Iterable[_KT], value: _VT | None = None) -> Self: ... # type: ignore[override]
|
||||
def updated(self, *a, **kw) -> Self: ...
|
||||
# Can't noqa because of https://github.com/plinss/flake8-noqa/pull/30
|
||||
# Signature conflicts with superclass, so let's just omit it
|
||||
# def __ior__(self, *a, **kw) -> NoReturn: ...
|
||||
def __ior__(self, *a, **kw) -> NoReturn: ... # type: ignore[misc] # noqa: Y034 # Signature conflicts with superclass
|
||||
def __setitem__(self, *a, **kw) -> NoReturn: ...
|
||||
def __delitem__(self, *a, **kw) -> NoReturn: ...
|
||||
def update(self, *a, **kw) -> NoReturn: ...
|
||||
|
||||
@@ -10,9 +10,6 @@ from pandas._typing import Scalar
|
||||
from ..base import _ConvertibleToCRS
|
||||
from ..geodataframe import GeoDataFrame
|
||||
|
||||
# inline ruff noqa at _SqlalchemyConnectionLike.__enter__ confuses flake8
|
||||
# ruff: noqa: PYI034
|
||||
|
||||
# Start SQLAlchemy hack
|
||||
# ---------------------
|
||||
# The code actually explicitly checks for SQLAlchemy's `Connection` and `Engine` with
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
# flake8: noqa: NQA102 # https://github.com/plinss/flake8-noqa/issues/22
|
||||
# six explicitly re-exports builtins. Normally this is something we'd want to avoid.
|
||||
# But this is specifically a compatibility package.
|
||||
from builtins import * # noqa: UP029
|
||||
|
||||
Reference in New Issue
Block a user