Skip to content

Commit 12b9e48

Browse files
authored
Update Ruff and enable F821 in stubs (#11771)
1 parent 6e16a4c commit 12b9e48

File tree

6 files changed

+13
-15
lines changed

6 files changed

+13
-15
lines changed

.flake8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[flake8]
22
# NQA: Ruff won't warn about redundant `# noqa: Y`
33
# Y: Flake8 is only used to run flake8-pyi, everything else is in Ruff
4-
# F821: Until https://github.com/astral-sh/ruff/issues/3011 is fixed, we need flake8-pyi's monkeypatching
4+
# F821: Typeshed is a testing ground for flake8-pyi, which monkeypatches F821
55
select = NQA, Y, F821
66
# Ignore rules normally excluded by default
77
extend-ignore = Y090

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ repos:
1111
args: [--fix=lf]
1212
- id: check-case-conflict
1313
- repo: https://github.com/astral-sh/ruff-pre-commit
14-
rev: v0.3.5 # must match requirements-tests.txt
14+
rev: v0.3.7 # must match requirements-tests.txt
1515
hooks:
1616
- id: ruff
1717
# Run this separately because we don't really want

pyproject.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,6 @@ ignore = [
9191
"E501", # Line too long
9292
"E741", # ambiguous variable name
9393
"F403", # `from . import *` used; unable to detect undefined names
94-
# False positives in stubs
95-
"F821", # Undefined name: https://github.com/astral-sh/ruff/issues/3011
9694
# Stubs can sometimes re-export entire modules.
9795
# Issues with using a star-imported name will be caught by type-checkers.
9896
"F405", # may be undefined, or defined from star imports

requirements-tests.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ mypy==1.9.0
99
pre-commit-hooks==4.5.0 # must match .pre-commit-config.yaml
1010
pyright==1.1.358
1111
pytype==2024.4.11; platform_system != "Windows" and python_version < "3.12"
12-
ruff==0.3.5 # must match .pre-commit-config.yaml
12+
ruff==0.3.7 # must match .pre-commit-config.yaml
1313

1414
# Libraries used by our various scripts.
1515
aiohttp==3.9.3

stdlib/typing.pyi

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,6 @@ if sys.version_info >= (3, 12):
132132
ContextManager = AbstractContextManager
133133
AsyncContextManager = AbstractAsyncContextManager
134134

135-
# This itself is only available during type checking
136-
def type_check_only(func_or_cls: _F) -> _F: ...
137-
138135
Any = object()
139136

140137
def final(f: _T) -> _T: ...
@@ -183,12 +180,6 @@ class _SpecialForm:
183180
def __or__(self, other: Any) -> _SpecialForm: ...
184181
def __ror__(self, other: Any) -> _SpecialForm: ...
185182

186-
_F = TypeVar("_F", bound=Callable[..., Any])
187-
_P = _ParamSpec("_P")
188-
_T = TypeVar("_T")
189-
190-
def overload(func: _F) -> _F: ...
191-
192183
Union: _SpecialForm
193184
Generic: _SpecialForm
194185
# Protocol is only present in 3.8 and later, but mypy needs it unconditionally
@@ -295,6 +286,10 @@ if sys.version_info >= (3, 10):
295286
else:
296287
def NewType(name: str, tp: Any) -> Any: ...
297288

289+
_F = TypeVar("_F", bound=Callable[..., Any])
290+
_P = _ParamSpec("_P")
291+
_T = TypeVar("_T")
292+
298293
# These type variables are used by the container types.
299294
_S = TypeVar("_S")
300295
_KT = TypeVar("_KT") # Key type.
@@ -304,9 +299,13 @@ _KT_co = TypeVar("_KT_co", covariant=True) # Key type covariant containers.
304299
_VT_co = TypeVar("_VT_co", covariant=True) # Value type covariant containers.
305300
_TC = TypeVar("_TC", bound=type[object])
306301

302+
def overload(func: _F) -> _F: ...
307303
def no_type_check(arg: _F) -> _F: ...
308304
def no_type_check_decorator(decorator: Callable[_P, _T]) -> Callable[_P, _T]: ...
309305

306+
# This itself is only available during type checking
307+
def type_check_only(func_or_cls: _F) -> _F: ...
308+
310309
# Type aliases and type constructors
311310

312311
class _Alias:

stubs/hdbcli/hdbcli/dbapi.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ from .resultrow import ResultRow
1111
apilevel: str
1212
threadsafety: int
1313
paramstyle: tuple[str, ...] # hdbcli defines it as a tuple which does not follow PEP 249
14-
connect = Connection
1514

1615
class Connection:
1716
def __init__(
@@ -40,6 +39,8 @@ class Connection:
4039
def setautocommit(self, auto: bool = ...) -> None: ...
4140
def setclientinfo(self, key: str, value: str | None = ...) -> None: ...
4241

42+
connect = Connection
43+
4344
class LOB:
4445
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
4546
def close(self) -> bool: ...

0 commit comments

Comments
 (0)