Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions lib/ts_utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from termcolor import colored as colored # pyright: ignore[reportAssignmentType]
except ImportError:

def colored(text: str, color: str | None = None, **kwargs: Any) -> str: # type: ignore[misc] # noqa: ARG001
def colored(text: str, color: str | None = None, **kwargs: Any) -> str: # type: ignore[misc] # ruff: ignore[unused-function-argument]
return text


Expand Down Expand Up @@ -179,7 +179,7 @@ def parse_stdlib_versions_file() -> SupportedVersions:
with VERSIONS_PATH.open(encoding="UTF-8") as f:
for line in f:
stripped_line = strip_comments(line)
if stripped_line == "":
if not stripped_line:
continue
m = VERSION_LINE_RE.match(stripped_line)
assert m, f"invalid VERSIONS line: {stripped_line}"
Expand Down Expand Up @@ -255,15 +255,21 @@ def allowlists(distribution_name: str) -> list[str]:
# For details, see https://github.com/python/typeshed/pull/13620#discussion_r1990185997
# Python 3.12 added a cross-platform solution with `tempfile.NamedTemporaryFile("w+", delete_on_close=False)`
if sys.platform != "win32":
NamedTemporaryFile = tempfile.NamedTemporaryFile # noqa: TID251
# We ignore the Ruff error here because this defines the helper that callers should use
# instead of `tempfile.NamedTemporaryFile`, which is banned by `banned-api`.
#
NamedTemporaryFile = tempfile.NamedTemporaryFile # ruff: ignore[banned-api]
else:

def NamedTemporaryFile(mode: OpenTextMode) -> TemporaryFileWrapper[str]: # noqa: N802
def NamedTemporaryFile(mode: OpenTextMode) -> TemporaryFileWrapper[str]: # ruff: ignore[invalid-function-name]
def close(self: TemporaryFileWrapper[str]) -> None:
TemporaryFileWrapper.close(self) # pyright: ignore[reportUnknownMemberType]
Path(self.name).unlink()

temp = tempfile.NamedTemporaryFile(mode, delete=False) # noqa: SIM115, TID251
# We ignore the `banned-api` Ruff error here because this call is part of the helper that callers should use
# instead of `tempfile.NamedTemporaryFile`.
#
temp = tempfile.NamedTemporaryFile(mode, delete=False) # ruff: ignore[open-file-with-context-handler, banned-api]
temp.close = MethodType(close, temp) # type: ignore[method-assign]
return temp

Expand Down
195 changes: 100 additions & 95 deletions pyproject.toml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion scripts/stubsabot.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ async def get_host_repo_info(session: aiohttp.ClientSession, stub_info: StubMeta
# so no need to repeat all of them here
split_url = urllib.parse.urlsplit(stub_info.upstream_repository)
host = split_url.netloc.removesuffix(".com")
if host not in ("github", "gitlab"):
if host not in {"github", "gitlab"}:
return None
url_path = split_url.path.strip("/")
assert len(Path(url_path).parts) == 2
Expand Down
2 changes: 1 addition & 1 deletion scripts/sync_protobuf/google_protobuf.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

def extract_python_version(file_path: Path) -> str:
"""Extract the Python version from https://github.com/protocolbuffers/protobuf/blob/main/version.json ."""
with file_path.open() as file:
with file_path.open(encoding="utf-8") as file:
data: dict[str, Any] = json.load(file)
# The root key will be the protobuf source code version
version = next(iter(data.values()))["languages"]["python"]
Expand Down
2 changes: 1 addition & 1 deletion scripts/sync_protobuf/s2clientprotocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

def extract_python_version(file_path: Path) -> str:
"""Extract Python version from s2clientprotocol's build file."""
match = re.search(VERSION_PATTERN, file_path.read_text())
match = re.search(VERSION_PATTERN, file_path.read_text(encoding="utf-8"))
assert match
return match.group(1)

Expand Down
2 changes: 1 addition & 1 deletion stdlib/_collections_abc.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sys
from abc import abstractmethod
from types import MappingProxyType
from typing import ( # noqa: Y022,Y038,UP035,Y057
from typing import ( # noqa: Y022,Y038,Y057 # ruff: ignore[deprecated-import]
AbstractSet as Set,
AsyncGenerator as AsyncGenerator,
AsyncIterable as AsyncIterable,
Expand Down
11 changes: 6 additions & 5 deletions stdlib/builtins.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ from types import CellType, CodeType, EllipsisType, GenericAlias, NotImplemented

# mypy crashes if any of {ByteString, Sequence, MutableSequence, Mapping, MutableMapping}
# are imported from collections.abc in builtins.pyi
from typing import ( # noqa: Y022,UP035
from typing import ( # noqa: Y022 # ruff: ignore[deprecated-import]
IO,
Any,
BinaryIO,
Expand Down Expand Up @@ -65,7 +65,8 @@ from typing import ( # noqa: Y022,UP035
)

# we can't import `Literal` from typing or mypy crashes: see #11247
from typing_extensions import Literal, LiteralString, Self, TypeIs, TypeVarTuple, deprecated, disjoint_base # noqa: Y023, UP035
# ruff: ignore[deprecated-import]
from typing_extensions import Literal, LiteralString, Self, TypeIs, TypeVarTuple, deprecated, disjoint_base # noqa: Y023

if sys.version_info >= (3, 14):
from _typeshed import AnnotateFunc
Expand All @@ -91,11 +92,11 @@ _P = ParamSpec("_P")

# Type variables for slice
_StartT_co = TypeVar("_StartT_co", covariant=True, default=Any) # slice -> slice[Any, Any, Any]
_StopT_co = TypeVar("_StopT_co", covariant=True, default=_StartT_co) # slice[A] -> slice[A, A, A]
_StopT_co = TypeVar("_StopT_co", covariant=True, default=_StartT_co) # slice[A] -> slice[A, A, A]
# NOTE: step could differ from start and stop, (e.g. datetime/timedelta)l
# the default (start|stop) is chosen to cater to the most common case of int/index slices.
# FIXME: https://github.com/python/typing/issues/213 (replace step=start|stop with step=start&stop)
_StepT_co = TypeVar("_StepT_co", covariant=True, default=_StartT_co | _StopT_co) # slice[A,B] -> slice[A, B, A|B]
_StepT_co = TypeVar("_StepT_co", covariant=True, default=_StartT_co | _StopT_co) # slice[A,B] -> slice[A, B, A|B]
Comment on lines 93 to +99

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these changes were due to an autofix by no-space-after-inline-comment, which also flags too many spaces after an inline comment #


@disjoint_base
class object:
Expand Down Expand Up @@ -1005,7 +1006,7 @@ class memoryview(Sequence[_I]):
def __enter__(self) -> Self: ...
def __exit__(
self,
exc_type: type[BaseException] | None, # noqa: PYI036 # This is the module declaring BaseException
exc_type: type[BaseException] | None, # ruff: ignore[bad-exit-annotation] # This is the module declaring BaseException
exc_val: BaseException | None,
exc_tb: TracebackType | None,
/,
Expand Down
2 changes: 1 addition & 1 deletion stdlib/email/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ from typing import TypeAlias, overload
# At runtime, listing submodules in __all__ without them being imported is
# valid, and causes them to be included in a star import. See #6523

__all__ = [ # noqa: F822 # Undefined names in __all__
__all__ = [ # ruff: ignore[undefined-export] # Undefined names in __all__
"base64mime", # pyright: ignore[reportUnsupportedDunderAll]
"charset", # pyright: ignore[reportUnsupportedDunderAll]
"encoders", # pyright: ignore[reportUnsupportedDunderAll]
Expand Down
2 changes: 1 addition & 1 deletion stdlib/typing.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Since this module defines "overload" it is not recognized by Ruff as typing.overload
# TODO: The collections import is required, otherwise mypy crashes.
# https://github.com/python/mypy/issues/16744
import collections # noqa: F401 # pyright: ignore[reportUnusedImport]
import collections # ruff: ignore[unused-import] # pyright: ignore[reportUnusedImport]
import sys
import typing_extensions
from _collections_abc import dict_items, dict_keys, dict_values
Expand Down
2 changes: 1 addition & 1 deletion stdlib/typing_extensions.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ from collections.abc import (
from contextlib import AbstractAsyncContextManager as AsyncContextManager, AbstractContextManager as ContextManager
from re import Match as Match, Pattern as Pattern
from types import GenericAlias, ModuleType, UnionType
from typing import ( # noqa: Y022,Y037,Y038,Y039,UP035
from typing import ( # noqa: Y022,Y037,Y038,Y039 # ruff: ignore[deprecated-import]
IO as IO,
TYPE_CHECKING as TYPE_CHECKING,
AbstractSet as AbstractSet,
Expand Down
2 changes: 1 addition & 1 deletion stdlib/xml/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# valid, and causes them to be included in a star import. See #6523
import sys

__all__ = ["dom", "parsers", "sax", "etree"] # noqa: F822 # pyright: ignore[reportUnsupportedDunderAll]
__all__ = ["dom", "parsers", "sax", "etree"] # ruff: ignore[undefined-export] # pyright: ignore[reportUnsupportedDunderAll]

if sys.version_info >= (3, 15):
__all__ += ["is_valid_name"] # pyright: ignore[reportUnsupportedDunderAll]
Expand Down
4 changes: 3 additions & 1 deletion stubs/gunicorn/gunicorn/_types.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
### This .pyi file is a helper for centralized storage types that are reused across different runtime modules. ###
############################################################################################################
# This .pyi file is a helper for centralized storage types that are reused across different runtime modules.
############################################################################################################
Comment on lines -1 to +3

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ruff flagged the old version of this comment with https://docs.astral.sh/ruff/rules/multiple-leading-hashes-for-block-comment/

from _typeshed import FileDescriptor
from collections.abc import Awaitable, Callable, Iterable, MutableMapping
from typing import Any, TypeAlias
Expand Down
10 changes: 2 additions & 8 deletions stubs/pika/pika/adapters/twisted_connection.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,8 @@ from pika.channel import Channel
from pika.connection import Connection, ConnectionParameters, Parameters
from pika.exchange_type import ExchangeType
from pika.spec import BasicProperties
from twisted.internet.base import ( # type: ignore[import-not-found] # pyright: ignore[reportMissingImports]
DelayedCall,
ReactorBase,
)
from twisted.internet.defer import ( # type: ignore[import-not-found] # pyright: ignore[reportMissingImports]
Deferred,
DeferredQueue,
)
from twisted.internet.base import DelayedCall, ReactorBase # type: ignore[import-not-found] # pyright: ignore[reportMissingImports]
from twisted.internet.defer import Deferred, DeferredQueue # type: ignore[import-not-found] # pyright: ignore[reportMissingImports]
from twisted.internet.interfaces import ITransport # type: ignore[import-not-found] # pyright: ignore[reportMissingImports]
from twisted.internet.protocol import Protocol # type: ignore[import-not-found] # pyright: ignore[reportMissingImports]
from twisted.python.failure import Failure # type: ignore[import-not-found] # pyright: ignore[reportMissingImports]
Expand Down
2 changes: 1 addition & 1 deletion stubs/psycopg2/psycopg2/_psycopg.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ class ConnectionInfo:
# [1]: https://www.psycopg.org/docs/extensions.html#psycopg2.extensions.ConnectionInfo
# [2]: https://github.com/psycopg/psycopg2/blob/1d3a89a0bba621dc1cc9b32db6d241bd2da85ad1/psycopg/conninfo_type.c#L52 and below
# [3]: https://www.postgresql.org/docs/current/libpq-status.html
# [4]: https://github.com/postgres/postgres/blob/b39838889e76274b107935fa8e8951baf0e8b31b/src/interfaces/libpq/fe-connect.c#L6754 and below # noqa: E501
# [4]: https://github.com/postgres/postgres/blob/b39838889e76274b107935fa8e8951baf0e8b31b/src/interfaces/libpq/fe-connect.c#L6754 and below # ruff: ignore[line-too-long]
@property
def backend_pid(self) -> int: ...
@property
Expand Down
2 changes: 1 addition & 1 deletion stubs/pyxdg/xdg/Menu.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class MenuEntry:
TYPE_SYSTEM: Literal["System"]
TYPE_BOTH: Literal["Both"]
DesktopEntry: DesktopEntry
Show: Literal[True, False, "Deleted", "NoDisplay", "Hidden", "Empty", "NotShowIn", "NoExec"]
Show: bool | Literal["Deleted", "NoDisplay", "Hidden", "Empty", "NotShowIn", "NoExec"]
Visible: Literal[1, 0, "Deleted", "NoDisplay", "Hidden", "Empty", "NotShowIn", "NoExec"]
Original: MenuEntry | None
Parents: list[Menu]
Expand Down
2 changes: 1 addition & 1 deletion stubs/reportlab/reportlab/lib/rltempfile.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ def get_rl_tempdir(*subdirs: str) -> str: ...
def get_rl_tempfile(fn: str | None = None) -> str: ...

# The duplicate entry matches the runtime __all__.
__all__ = ("get_rl_tempdir", "get_rl_tempdir") # noqa: RUF068
__all__ = ("get_rl_tempdir", "get_rl_tempdir") # ruff: ignore[duplicate-entry-in-dunder-all]
2 changes: 1 addition & 1 deletion stubs/six/six/moves/builtins.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# 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
from builtins import * # ruff: ignore[unnecessary-builtin-import]
2 changes: 1 addition & 1 deletion stubs/workalendar/workalendar/europe/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ __all__ = (
"ValencianCommunity",
# Switzerland
# The duplicate entry matches the runtime __all__.
"Switzerland", # noqa: RUF068
"Switzerland", # ruff: ignore[duplicate-entry-in-dunder-all]
"Aargau",
"AppenzellInnerrhoden",
"AppenzellAusserrhoden",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ __all__ = [
"SpringHolidayFirstMondayJune",
"VictoriaDayFourthMondayMay",
"VictoriaDayLastMondayMay",
"VictoriaDayTuesdayAfterFirstMondayMay", # noqa: F822 # pyright: ignore[reportUnsupportedDunderAll] see https://github.com/workalendar/workalendar/pull/778 # pyrefly: ignore [bad-dunder-all]
"VictoriaDayTuesdayAfterFirstMondayMay", # ruff: ignore[undefined-export] # pyright: ignore[reportUnsupportedDunderAll] # pyrefly: ignore [bad-dunder-all] # see https://github.com/workalendar/workalendar/pull/778
"VictoriaDayFirstMondayJune",
"FairHolidayLastMondayJune",
"FairHolidayFirstMondayJuly",
Expand Down
1 change: 0 additions & 1 deletion stubs/yt-dlp/yt_dlp/compat/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import datetime
import urllib
import urllib.request
import xml.etree.ElementTree as etree

Expand Down
15 changes: 6 additions & 9 deletions stubs/yt-dlp/yt_dlp/utils/_jsruntime.pyi

@AlexWaygood AlexWaygood Oct 7, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ruff flagged the old @cached_property/@abstractmethod combination under incorrect-decorator-order, a preview-only rule. In the pinned 2026.08.19 source, info is a cached property that calls the abstract _info method, which is implemented by each runtime.

Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,22 @@ class JsRuntimeInfo:
class JsRuntime(abc.ABC):
def __init__(self, path: str | None = None) -> None: ...
@cached_property
@abc.abstractmethod
def info(self) -> JsRuntimeInfo | None: ...
@abc.abstractmethod
def _info(self) -> JsRuntimeInfo | None: ...

class DenoJsRuntime(JsRuntime):
MIN_SUPPORTED_VERSION: Final[tuple[int, int, int]]
@cached_property
def info(self) -> JsRuntimeInfo | None: ...
def _info(self) -> JsRuntimeInfo | None: ...

class BunJsRuntime(JsRuntime):
MIN_SUPPORTED_VERSION: Final[tuple[int, int, int]]
@cached_property
def info(self) -> JsRuntimeInfo | None: ...
def _info(self) -> JsRuntimeInfo | None: ...

class NodeJsRuntime(JsRuntime):
MIN_SUPPORTED_VERSION: Final[tuple[int, int, int]]
@cached_property
def info(self) -> JsRuntimeInfo | None: ...
def _info(self) -> JsRuntimeInfo | None: ...

class QuickJsRuntime(JsRuntime):
MIN_SUPPORTED_VERSION: Final[tuple[int, int, int]]
@cached_property
def info(self) -> JsRuntimeInfo | None: ...
def _info(self) -> JsRuntimeInfo | None: ...
2 changes: 1 addition & 1 deletion tests/mypy_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

# Fail early if mypy isn't installed
try:
import mypy # pyright: ignore[reportUnusedImport] # noqa: F401
import mypy # pyright: ignore[reportUnusedImport] # ruff: ignore[unused-import]
except ImportError:
print_error("Cannot import mypy. Did you install it?")
sys.exit(1)
Expand Down
Loading