Fix invalid noqa comments and poorly formatted type ignores (#11497)

This commit is contained in:
Avasam
2024-02-29 01:27:07 -05:00
committed by GitHub
parent 5e9589dd75
commit c75ecf0bca
21 changed files with 43 additions and 43 deletions

View File

@@ -35,11 +35,11 @@ field.process(None, extra_filters=[Filter1(), Filter2()])
# but if we pass in some callables with an incompatible param spec
# then we should get type errors
Field(filters=(str.upper, str.lower, int, not_a_filter)) # type:ignore
Field(filters=(Filter1(), Filter2(), also_not_a_filter)) # type:ignore
Field(filters=[str.upper, str.lower, int, also_not_a_filter]) # type:ignore
Field(filters=[Filter1(), Filter2(), not_a_filter]) # type:ignore
field.process(None, extra_filters=(str.upper, str.lower, int, not_a_filter)) # type:ignore
field.process(None, extra_filters=(Filter1(), Filter2(), also_not_a_filter)) # type:ignore
field.process(None, extra_filters=[str.upper, str.lower, int, also_not_a_filter]) # type:ignore
field.process(None, extra_filters=[Filter1(), Filter2(), not_a_filter]) # type:ignore
Field(filters=(str.upper, str.lower, int, not_a_filter)) # type: ignore
Field(filters=(Filter1(), Filter2(), also_not_a_filter)) # type: ignore
Field(filters=[str.upper, str.lower, int, also_not_a_filter]) # type: ignore
Field(filters=[Filter1(), Filter2(), not_a_filter]) # type: ignore
field.process(None, extra_filters=(str.upper, str.lower, int, not_a_filter)) # type: ignore
field.process(None, extra_filters=(Filter1(), Filter2(), also_not_a_filter)) # type: ignore
field.process(None, extra_filters=[str.upper, str.lower, int, also_not_a_filter]) # type: ignore
field.process(None, extra_filters=[Filter1(), Filter2(), not_a_filter]) # type: ignore

View File

@@ -14,16 +14,16 @@ string_field = StringField(validators=(Optional(), Email()))
string_field.validate(form, (Optional(), Email()))
# but not on Field
field = Field(validators=(Optional(), Email())) # type:ignore
field.validate(form, (Optional(), Email())) # type:ignore
field = Field(validators=(Optional(), Email())) # type: ignore
field.validate(form, (Optional(), Email())) # type: ignore
# unless we only pass the Field validator
Field(validators=(Optional(),))
field.validate(form, (Optional(),))
# DateField should accept Field validators but not StringField validators
date_field = DateField(validators=(Optional(), Email())) # type:ignore
date_field.validate(form, (Optional(), Email())) # type:ignore
date_field = DateField(validators=(Optional(), Email())) # type: ignore
date_field.validate(form, (Optional(), Email())) # type: ignore
DateField(validators=(Optional(),))
# for lists we can't be as strict so we won't get type errors here

View File

@@ -5,8 +5,8 @@ from wtforms.widgets import Input, ListWidget, Option, Select, TableWidget, Text
# more specific widgets should only work on more specific fields
Field(widget=Input())
Field(widget=TextArea()) # type:ignore
Field(widget=Select()) # type:ignore
Field(widget=TextArea()) # type: ignore
Field(widget=Select()) # type: ignore
# less specific widgets are fine, even if they're often not what you want
StringField(widget=Input())
@@ -15,7 +15,7 @@ StringField(widget=TextArea())
SelectField(widget=Input(), option_widget=Input())
SelectField(widget=Select(), option_widget=Option())
# a more specific type other than Option widget is not allowed
SelectField(widget=Select(), option_widget=TextArea()) # type:ignore
SelectField(widget=Select(), option_widget=TextArea()) # type: ignore
# we should be able to pass Field() even though it wants an unbound_field
# this gets around __new__ not working in type checking

View File

@@ -83,7 +83,7 @@ class _ResponseCacheControl(_BaseCacheControl):
stale_if_error: _IntValueProperty[None]
class _AnyCacheControl(_RequestCacheControl, _ResponseCacheControl):
type: None # type:ignore[assignment]
type: None # type: ignore[assignment]
class CacheControl(_AnyCacheControl):
@overload

View File

@@ -41,9 +41,9 @@ class Cookie(dict[str, Morsel]):
def __init__(self, input: str | None = None) -> None: ...
def load(self, data: str) -> None: ...
def add(self, key: str | bytes, val: str | bytes) -> Morsel: ...
def __setitem__(self, key: str | bytes, val: str | bytes) -> Morsel: ... # type:ignore[override]
def __setitem__(self, key: str | bytes, val: str | bytes) -> Morsel: ... # type: ignore[override]
def serialize(self, full: bool = True) -> str: ...
def values(self) -> list[Morsel]: ... # type:ignore[override]
def values(self) -> list[Morsel]: ... # type: ignore[override]
def __str__(self, full: bool = True) -> str: ...
class Morsel(dict[bytes, bytes | bool | None]):

View File

@@ -40,8 +40,8 @@ class WSGIHTTPException(Response, HTTPException):
def json_body(self, environ: WSGIEnvironment) -> str: ...
def generate_response(self, environ: WSGIEnvironment, start_response: StartResponse) -> Iterable[bytes]: ...
@property
def wsgi_response(self) -> Self: ... # type:ignore[override]
def __str__(self) -> str: ... # type:ignore[override] # noqaY029
def wsgi_response(self) -> Self: ... # type: ignore[override]
def __str__(self) -> str: ... # type: ignore[override] # noqa: Y029
class HTTPError(WSGIHTTPException): ...
class HTTPRedirection(WSGIHTTPException): ...

View File

@@ -11,7 +11,7 @@ class EnvironHeaders(MutableMapping[str, str]):
def __getitem__(self, hname: str) -> str: ...
def __setitem__(self, hname: str, value: str) -> None: ...
def __delitem__(self, hname: str) -> None: ...
def keys(self) -> list[str]: ... # type:ignore[override]
def keys(self) -> list[str]: ... # type: ignore[override]
def __contains__(self, hname: object) -> bool: ...
def __len__(self) -> int: ...
def __iter__(self) -> Iterator[str]: ...

View File

@@ -45,7 +45,7 @@ class MultiDict(MutableMapping[_KT, _VT]):
@overload
def pop(self, key: _KT, default: _T) -> _VT | _T: ...
def popitem(self) -> tuple[_KT, _VT]: ...
@overload # type:ignore[override]
@overload # type: ignore[override]
def update(self, __m: Collection[tuple[_KT, _VT]], **kwargs: _VT) -> None: ...
@overload
def update(self, **kwargs: _VT) -> None: ...
@@ -58,10 +58,10 @@ class MultiDict(MutableMapping[_KT, _VT]):
@overload
def extend(self, other: None = None, **kwargs: _VT) -> None: ...
def __len__(self) -> int: ...
def keys(self) -> Iterator[_KT]: ... # type:ignore[override]
def keys(self) -> Iterator[_KT]: ... # type: ignore[override]
__iter__ = keys
def values(self) -> Iterator[_VT]: ... # type:ignore[override]
def items(self) -> Iterator[tuple[_KT, _VT]]: ... # type:ignore[override]
def values(self) -> Iterator[_VT]: ... # type: ignore[override]
def items(self) -> Iterator[tuple[_KT, _VT]]: ... # type: ignore[override]
class GetDict(MultiDict[str, str]):
env: WSGIEnvironment
@@ -82,7 +82,7 @@ class NestedMultiDict(MultiDict[_KT, _VT]):
def pop(self, key: _KT, default: Any = ...) -> Any: ...
def popitem(self) -> tuple[_KT, _VT]: ...
def update(self, *args: Any, **kwargs: _VT) -> None: ...
def copy(self) -> MultiDict[_KT, _VT]: ... # type:ignore[override]
def copy(self) -> MultiDict[_KT, _VT]: ... # type: ignore[override]
class NoVars:
reason: str

View File

@@ -70,7 +70,7 @@ class CoffeeScript(CommandlineBase, Compiler):
name: ClassVar[Literal["coffee"]]
command: ClassVar[Literal["coffee"]]
source_extension = NotImplemented
def process( # type:ignore[override]
def process( # type: ignore[override]
self, source: StrOrBytesPath | _SourceType, target: StrOrBytesPath | _TargetType
) -> None: ...

View File

@@ -174,7 +174,7 @@ class Group(Dependable):
depends: set[Dependable]
supports: set[Dependable]
def __init__(self, depends: Iterable[Dependable]) -> None: ...
def set_dependencies(self, depends: Iterable[Dependable]) -> None: ... # type:ignore[override]
def set_dependencies(self, depends: Iterable[Dependable]) -> None: ... # type: ignore[override]
def list_assets(self) -> set[Asset]: ...
def need(self, slots: dict[Slot, Resource] | None = None) -> None: ...

View File

@@ -21,7 +21,7 @@ class Registry(dict[str, _NamedT]):
@property
@abstractmethod
def ENTRY_POINT(self) -> str: ...
def __init__(self, items: Iterable[_NamedT] = ()) -> None: ... # noqaY011
def __init__(self, items: Iterable[_NamedT] = ()) -> None: ...
def add(self, item: _NamedT) -> None: ...
def load_items_from_entry_points(self) -> None: ...
def make_item_from_entry_point(self, entry_point: EntryPoint) -> Any: ...

View File

@@ -34,7 +34,7 @@ class ThreadPool(GroupMappingMixin):
def join(self) -> None: ...
def kill(self) -> None: ...
def adjust(self) -> None: ...
def spawn(self, func: Callable[_P, _T], *args: _P.args, **kwargs: _P.kwargs) -> AsyncResult[_T]: ... # type:ignore[override]
def spawn(self, func: Callable[_P, _T], *args: _P.args, **kwargs: _P.kwargs) -> AsyncResult[_T]: ... # type: ignore[override]
class ThreadResult(Generic[_T]):
receiver: _Receiver[_T]

View File

@@ -179,13 +179,13 @@ class OleFileIO:
raise_defects: int = 40,
write_mode: bool = False,
debug: bool = False,
path_encoding: str | None = DEFAULT_PATH_ENCODING, # noqaY011
path_encoding: str | None = DEFAULT_PATH_ENCODING, # noqa: Y011
) -> None: ...
def __del__(self) -> None: ...
def __enter__(self) -> Self: ...
def __exit__(self, *args: object) -> None: ...
def _raise_defect(
self, defect_level: int, message: str, exception_type: type[Exception] = OleFileError # noqaY011
self, defect_level: int, message: str, exception_type: type[Exception] = OleFileError # noqa: Y011
) -> None: ...
def _decode_utf16_str(self, utf16_str: bytes, errors: str = "replace") -> bytes: ...
def open(self, filename: IO[bytes] | bytes | str, write_mode: bool = False) -> None: ...

View File

@@ -55,4 +55,4 @@ class Chartsheet(_WorkbookChild, Serialisable):
sheet_state: _VisibilityType = "visible",
) -> None: ...
def add_chart(self, chart) -> None: ...
def to_tree(self) -> Element: ... # type:ignore[override]
def to_tree(self) -> Element: ... # type: ignore[override]

View File

@@ -144,7 +144,7 @@ class Max(Convertible[_M, _N]):
allow_none: Literal[False] = False,
max: float,
) -> None: ...
@overload # type:ignore[override] # Different restrictions
@overload # type: ignore[override] # Different restrictions
def __set__(self: Max[int, Literal[True]], instance: Serialisable | Strict, value: ConvertibleToInt | None) -> None: ...
@overload
def __set__(self: Max[int, Literal[False]], instance: Serialisable | Strict, value: ConvertibleToInt) -> None: ...
@@ -178,7 +178,7 @@ class Min(Convertible[_M, _N]):
allow_none: Literal[False] = False,
min: float,
) -> None: ...
@overload # type:ignore[override] # Different restrictions
@overload # type: ignore[override] # Different restrictions
def __set__(self: Min[int, Literal[True]], instance: Serialisable | Strict, value: ConvertibleToInt | None) -> None: ...
@overload
def __set__(self: Min[int, Literal[False]], instance: Serialisable | Strict, value: ConvertibleToInt) -> None: ...

View File

@@ -234,7 +234,7 @@ class NestedMinMax(Nested[_M], MinMax[_M, _N]): # type: ignore[misc]
def __get__(self: NestedMinMax[_M, Literal[True]], instance: Serialisable | Strict, cls: type | None = None) -> _M | None: ...
@overload
def __get__(self: NestedMinMax[_M, Literal[False]], instance: Serialisable | Strict, cls: type | None = None) -> _M: ...
@overload # type:ignore[override] # Different restrictions
@overload # type: ignore[override] # Different restrictions
def __set__(
self: NestedMinMax[int, Literal[True]],
instance: Serialisable | Strict,

View File

@@ -3,19 +3,19 @@ from typing import ClassVar
from .geometry import Point2D, PositiveSize2D, Transform2D
class XDRPoint2D(Point2D):
namespace: ClassVar[None] # type:ignore[assignment]
namespace: ClassVar[None] # type: ignore[assignment]
# Same as parent
# x = Point2D.x
# y = Point2D.y
class XDRPositiveSize2D(PositiveSize2D):
namespace: ClassVar[None] # type:ignore[assignment]
namespace: ClassVar[None] # type: ignore[assignment]
# Same as parent
# cx = PositiveSize2D.cx
# cy = PositiveSize2D.cy
class XDRTransform2D(Transform2D):
namespace: ClassVar[None] # type:ignore[assignment]
namespace: ClassVar[None] # type: ignore[assignment]
# Same as parent
# rot = Transform2D.rot
# flipH = Transform2D.flipH

View File

@@ -73,7 +73,7 @@ class ColumnDimension(Dimension):
width: Float[Literal[False]]
bestFit: Bool[Literal[False]]
auto_size: Alias
index: String[Literal[False]] # type:ignore[assignment]
index: String[Literal[False]] # type: ignore[assignment]
min: Integer[Literal[True]]
max: Integer[Literal[True]]
collapsed: Bool[Literal[False]]

View File

@@ -173,7 +173,7 @@ class DynamicFilter(Serialisable):
class CustomFilterValueDescriptor(Convertible[float | str, _N]):
pattern: Pattern[str]
expected_type: type[float | str]
@overload # type:ignore[override] # Different restrictions
@overload # type: ignore[override] # Different restrictions
def __set__(
self: CustomFilterValueDescriptor[Literal[True]], instance: Serialisable | Strict, value: str | ConvertibleToFloat | None
) -> None: ...

View File

@@ -59,7 +59,7 @@ class DirectorySandbox(AbstractSandbox):
write_ops: Any
def __init__(self, sandbox, exceptions=...) -> None: ...
def tmpnam(self) -> None: ...
def open(self, file, flags, mode: int = 511, *args, **kw): ... # type:ignore[override]
def open(self, file, flags, mode: int = 511, *args, **kw): ... # type: ignore[override]
class SandboxViolation(DistutilsError):
tmpl: Any

View File

@@ -63,7 +63,7 @@ class TranslationString(str):
mapping: dict[str, Any] | None = None,
context: str | None = None,
) -> Self: ...
def __mod__(self, options: dict[str, Any]) -> TranslationString: ... # type:ignore[override]
def __mod__(self, options: dict[str, Any]) -> TranslationString: ... # type: ignore[override]
def interpolate(self, translated: str | None = None) -> str: ...
def __reduce__(self) -> tuple[type[Self], tuple[str, str | None, str, dict[str, Any], str | None]]: ...