Skip to content

Use error codes for type ignores #8280

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 12, 2022
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
3 changes: 2 additions & 1 deletion pyrightconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
"reportUnboundVariable": "error",
"reportInvalidStubStatement": "error",
"reportInvalidTypeVarUse": "error",
"reportSelfClsParameterName": "error",
"reportUnsupportedDunderAll": "error",
"reportInconsistentConstructor": "error",
"reportTypeCommentUsage": "error",
Expand All @@ -52,4 +51,6 @@
// (which is stricter than mypy's; see mypy issue #10143 and #10157)
// would cause many false positives and catch few bugs.
"reportOverlappingOverload": "none",
// The name of the self/cls parameter is out of typeshed's control.
"reportSelfClsParameterName": "none",
}
3 changes: 2 additions & 1 deletion pyrightconfig.stricter.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@
"reportUnboundVariable": "error",
"reportInvalidStubStatement": "error",
"reportInvalidTypeVarUse": "error",
"reportSelfClsParameterName": "error",
"reportUnsupportedDunderAll": "error",
"reportInconsistentConstructor": "error",
"reportTypeCommentUsage": "error",
Expand All @@ -127,4 +126,6 @@
// (which is stricter than mypy's; see mypy issue #10143 and #10157)
// would cause many false positives and catch few bugs.
"reportOverlappingOverload": "none",
// The name of the self/cls parameter is out of typeshed's control.
"reportSelfClsParameterName": "none",
}
2 changes: 1 addition & 1 deletion stdlib/builtins.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class object:
def __class__(self: Self) -> type[Self]: ...
# Ignore errors about type mismatch between property getter and setter
@__class__.setter
def __class__(self, __type: type[object]) -> None: ... # type: ignore # noqa: F811
def __class__(self, __type: type[object]) -> None: ... # noqa: F811
def __init__(self) -> None: ...
def __new__(cls: type[Self]) -> Self: ...
# N.B. `object.__setattr__` and `object.__delattr__` are heavily special-cased by type checkers.
Expand Down
2 changes: 1 addition & 1 deletion stdlib/ctypes/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ class _SimpleCData(Generic[_T], _CData):
value: _T
# The TypeVar can be unsolved here,
# but we can't use overloads without creating many, many mypy false-positive errors
def __init__(self, value: _T = ...) -> None: ... # type: ignore
def __init__(self, value: _T = ...) -> None: ... # pyright: ignore[reportInvalidTypeVarUse]

class c_byte(_SimpleCData[int]): ...

Expand Down
6 changes: 3 additions & 3 deletions stdlib/enum.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class _EnumDict(dict[str, Any]):
class EnumMeta(ABCMeta):
if sys.version_info >= (3, 11):
def __new__(
metacls: type[Self], # type: ignore
metacls: type[Self],
cls: str,
bases: tuple[type, ...],
classdict: _EnumDict,
Expand All @@ -90,9 +90,9 @@ class EnumMeta(ABCMeta):
**kwds: Any,
) -> Self: ...
elif sys.version_info >= (3, 9):
def __new__(metacls: type[Self], cls: str, bases: tuple[type, ...], classdict: _EnumDict, **kwds: Any) -> Self: ... # type: ignore
def __new__(metacls: type[Self], cls: str, bases: tuple[type, ...], classdict: _EnumDict, **kwds: Any) -> Self: ...
else:
def __new__(metacls: type[Self], cls: str, bases: tuple[type, ...], classdict: _EnumDict) -> Self: ... # type: ignore
def __new__(metacls: type[Self], cls: str, bases: tuple[type, ...], classdict: _EnumDict) -> Self: ...

if sys.version_info >= (3, 9):
@classmethod
Expand Down
2 changes: 1 addition & 1 deletion stdlib/importlib/metadata/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class MetadataPathFinder(DistributionFinder):
def find_distributions(cls, context: DistributionFinder.Context = ...) -> Iterable[PathDistribution]: ...
if sys.version_info >= (3, 10):
# Yes, this is an instance method that has argumend named "cls"
def invalidate_caches(cls) -> None: ... # type: ignore
def invalidate_caches(cls) -> None: ...

class PathDistribution(Distribution):
def __init__(self, path: Path) -> None: ...
Expand Down
10 changes: 8 additions & 2 deletions stdlib/subprocess.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,14 @@ class CompletedProcess(Generic[_T]):
# and writing all the overloads would be horrific.
stdout: _T
stderr: _T
# type ignore on __init__ because the TypeVar can technically be unsolved, but see comment above
def __init__(self, args: _CMD, returncode: int, stdout: _T | None = ..., stderr: _T | None = ...) -> None: ... # type: ignore
# pyright ignore on __init__ because the TypeVar can technically be unsolved, but see comment above
def __init__(
self,
args: _CMD,
returncode: int,
stdout: _T | None = ..., # pyright: ignore[reportInvalidTypeVarUse]
stderr: _T | None = ..., # pyright: ignore[reportInvalidTypeVarUse]
) -> None: ...
def check_returncode(self) -> None: ...
if sys.version_info >= (3, 9):
def __class_getitem__(cls, item: Any) -> GenericAlias: ...
Expand Down
2 changes: 1 addition & 1 deletion stdlib/typing.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,7 @@ class _TypedDict(Mapping[str, object], metaclass=ABCMeta):
# can go through.
def setdefault(self, k: NoReturn, default: object) -> object: ...
# Mypy plugin hook for 'pop' expects that 'default' has a type variable type.
def pop(self, k: NoReturn, default: _T = ...) -> object: ... # type: ignore
def pop(self, k: NoReturn, default: _T = ...) -> object: ... # pyright: ignore[reportInvalidTypeVarUse]
def update(self: _T, __m: _T) -> None: ...
def __delitem__(self, k: NoReturn) -> None: ...
def items(self) -> ItemsView[str, object]: ...
Expand Down
2 changes: 1 addition & 1 deletion stdlib/typing_extensions.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class _TypedDict(Mapping[str, object], metaclass=abc.ABCMeta):
# can go through.
def setdefault(self, k: NoReturn, default: object) -> object: ...
# Mypy plugin hook for 'pop' expects that 'default' has a type variable type.
def pop(self, k: NoReturn, default: _T = ...) -> object: ... # type: ignore
def pop(self, k: NoReturn, default: _T = ...) -> object: ... # pyright: ignore[reportInvalidTypeVarUse]
def update(self: _T, __m: _T) -> None: ...
def items(self) -> ItemsView[str, object]: ...
def keys(self) -> KeysView[str]: ...
Expand Down
2 changes: 1 addition & 1 deletion stdlib/weakref.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class WeakValueDictionary(MutableMapping[_KT, _VT]):
class KeyedRef(ref[_T], Generic[_KT, _T]):
key: _KT
# This __new__ method uses a non-standard name for the "cls" parameter
def __new__(type: type[Self], ob: _T, callback: Callable[[_T], Any], key: _KT) -> Self: ... # type: ignore
def __new__(type: type[Self], ob: _T, callback: Callable[[_T], Any], key: _KT) -> Self: ...
def __init__(self, ob: _T, callback: Callable[[_T], Any], key: _KT) -> None: ...

class WeakKeyDictionary(MutableMapping[_KT, _VT]):
Expand Down
2 changes: 1 addition & 1 deletion stubs/SQLAlchemy/sqlalchemy/dialects/mysql/enumerated.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ from typing import Any
from ...sql import sqltypes
from .types import _StringType

class ENUM(sqltypes.NativeForEmulated, sqltypes.Enum, _StringType): # type: ignore # incompatible with base class
class ENUM(sqltypes.NativeForEmulated, sqltypes.Enum, _StringType): # type: ignore[misc] # incompatible with base class
__visit_name__: str
native_enum: bool
def __init__(self, *enums, **kw) -> None: ...
Expand Down
2 changes: 1 addition & 1 deletion stubs/SQLAlchemy/sqlalchemy/dialects/mysql/types.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class _StringType(sqltypes.String):
**kw,
) -> None: ...

class _MatchType(sqltypes.Float, sqltypes.MatchType): # type: ignore # incompatible with base class
class _MatchType(sqltypes.Float, sqltypes.MatchType): # type: ignore[misc] # incompatible with base class
def __init__(self, **kw) -> None: ...

class NUMERIC(_NumericType, sqltypes.NUMERIC):
Expand Down
2 changes: 1 addition & 1 deletion stubs/SQLAlchemy/sqlalchemy/dialects/postgresql/base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ PGUuid = UUID
class TSVECTOR(sqltypes.TypeEngine):
__visit_name__: str

class ENUM(sqltypes.NativeForEmulated, sqltypes.Enum): # type: ignore # base classes incompatible
class ENUM(sqltypes.NativeForEmulated, sqltypes.Enum): # type: ignore[misc] # base classes incompatible
native_enum: bool
create_type: Any
def __init__(self, *enums, **kw) -> None: ...
Expand Down
2 changes: 1 addition & 1 deletion stubs/mypy-extensions/mypy_extensions.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class _TypedDict(Mapping[str, object], metaclass=abc.ABCMeta):
# can go through.
def setdefault(self, k: NoReturn, default: object) -> object: ...
# Mypy plugin hook for 'pop' expects that 'default' has a type variable type.
def pop(self, k: NoReturn, default: _T = ...) -> object: ... # type: ignore
def pop(self, k: NoReturn, default: _T = ...) -> object: ... # pyright: ignore[reportInvalidTypeVarUse]
def update(self: Self, __m: Self) -> None: ...
def items(self) -> ItemsView[str, object]: ...
def keys(self) -> KeysView[str]: ...
Expand Down
2 changes: 1 addition & 1 deletion stubs/passlib/passlib/handlers/argon2.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class _Argon2Common( # type: ignore[misc]
min_memory_cost: ClassVar[int]
max_threads: ClassVar[int]
pure_use_threads: ClassVar[bool]
def type_values(cls): ... # type: ignore
def type_values(cls): ...
type: str
parallelism: int
version: int
Expand Down
2 changes: 1 addition & 1 deletion stubs/passlib/passlib/totp.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class TOTP:
def pretty_key(self, format: str = ..., sep: str = ...): ...
@classmethod
def normalize_time(cls, time): ...
def normalize_token(self_or_cls, token): ... # type: ignore
def normalize_token(self_or_cls, token): ...
def generate(self, time: Any | None = ...): ...
@classmethod
def verify(cls, token, source, **kwds): ...
Expand Down
3 changes: 2 additions & 1 deletion stubs/prettytable/prettytable/colortable.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ class Theme:
junction_char: str = ...,
junction_color: str = ...,
) -> None: ...
def format_code(s: str) -> str: ... # type: ignore
# The following method is broken in upstream code.
def format_code(s: str) -> str: ... # type: ignore[misc]

class Themes:
DEFAULT: ClassVar[Theme]
Expand Down