From 2b9f200e7e111ab714217b7846b80538e875b472 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Mon, 16 Jan 2023 22:52:40 +0000 Subject: [PATCH] Reenable flake8-pyi's Y011 and Y015 (#9551) --- .flake8 | 8 ++---- stubs/PyScreeze/pyscreeze/__init__.pyi | 3 +-- stubs/pywin32/win32/lib/ntsecuritycon.pyi | 30 +++++++++++++---------- stubs/tensorflow/tensorflow/__init__.pyi | 8 +++--- 4 files changed, 23 insertions(+), 26 deletions(-) diff --git a/.flake8 b/.flake8 index ef4615d62f37..2726e9c0e365 100644 --- a/.flake8 +++ b/.flake8 @@ -23,22 +23,18 @@ # Currently can't be enabled due to a few lingering bugs in mypy regarding # PEP 604 type aliases (see #4819). -# Outdated rules in flake8-pyi that should possibly be deprecated altogether: -# Y011 All default values for typed function arguments must be `...` -# Y015 Attribute must not have a default value other than `...` -# # A bugbear rule that has many false positives: # B028 consider using the `!r` conversion flag instead of manually surrounding things in quotes [flake8] per-file-ignores = *.py: B028, E203, E301, E302, E305, E501 - *.pyi: B, E301, E302, E305, E501, E701, E741, F401, F403, F405, F822, Y011, Y015, Y037 + *.pyi: B, E301, E302, E305, E501, E701, E741, F401, F403, F405, F822, Y037 # Since typing.pyi defines "overload" this is not recognized by flake8 as typing.overload. # Unfortunately, flake8 does not allow to "noqa" just a specific error inside the file itself. # https://github.com/PyCQA/flake8/issues/1079 # F811 redefinition of unused '...' - stdlib/typing.pyi: B, E301, E302, E305, E501, E701, E741, F401, F403, F405, F811, F822, Y011, Y015, Y037 + stdlib/typing.pyi: B, E301, E302, E305, E501, E701, E741, F401, F403, F405, F811, F822, Y037 # Generated protobuf files include docstrings *_pb2.pyi: B, E301, E302, E305, E501, E701, Y021, Y026 diff --git a/stubs/PyScreeze/pyscreeze/__init__.pyi b/stubs/PyScreeze/pyscreeze/__init__.pyi index 9821a253aa43..ca1d590d6c7c 100644 --- a/stubs/PyScreeze/pyscreeze/__init__.pyi +++ b/stubs/PyScreeze/pyscreeze/__init__.pyi @@ -1,4 +1,3 @@ -import sys from _typeshed import Incomplete, StrOrBytesPath from collections.abc import Callable, Generator from typing import NamedTuple, SupportsFloat, TypeVar, overload @@ -18,7 +17,7 @@ _R = TypeVar("_R") _Mat: TypeAlias = Incomplete useOpenCV: bool -RUNNING_PYTHON_2 = sys.version_info < (3,) +RUNNING_PYTHON_2: Literal[False] GRAYSCALE_DEFAULT: Literal[False] USE_IMAGE_NOT_FOUND_EXCEPTION: bool scrotExists: bool diff --git a/stubs/pywin32/win32/lib/ntsecuritycon.pyi b/stubs/pywin32/win32/lib/ntsecuritycon.pyi index 4dc485f652cd..19bb7a9d5b8b 100644 --- a/stubs/pywin32/win32/lib/ntsecuritycon.pyi +++ b/stubs/pywin32/win32/lib/ntsecuritycon.pyi @@ -1,3 +1,7 @@ +from typing_extensions import TypeAlias + +_SixIntTuple: TypeAlias = tuple[int, int, int, int, int, int] + DELETE: int READ_CONTROL: int WRITE_DAC: int @@ -32,12 +36,12 @@ FILE_ALL_ACCESS: int FILE_GENERIC_READ: int FILE_GENERIC_WRITE: int FILE_GENERIC_EXECUTE: int -SECURITY_NULL_SID_AUTHORITY = (0, 0, 0, 0, 0, 0) -SECURITY_WORLD_SID_AUTHORITY = (0, 0, 0, 0, 0, 1) -SECURITY_LOCAL_SID_AUTHORITY = (0, 0, 0, 0, 0, 2) -SECURITY_CREATOR_SID_AUTHORITY = (0, 0, 0, 0, 0, 3) -SECURITY_NON_UNIQUE_AUTHORITY = (0, 0, 0, 0, 0, 4) -SECURITY_RESOURCE_MANAGER_AUTHORITY = (0, 0, 0, 0, 0, 9) +SECURITY_NULL_SID_AUTHORITY: _SixIntTuple +SECURITY_WORLD_SID_AUTHORITY: _SixIntTuple +SECURITY_LOCAL_SID_AUTHORITY: _SixIntTuple +SECURITY_CREATOR_SID_AUTHORITY: _SixIntTuple +SECURITY_NON_UNIQUE_AUTHORITY: _SixIntTuple +SECURITY_RESOURCE_MANAGER_AUTHORITY: _SixIntTuple SECURITY_NULL_RID: int SECURITY_WORLD_RID: int SECURITY_LOCAL_RID: int @@ -46,7 +50,7 @@ SECURITY_CREATOR_GROUP_RID: int SECURITY_CREATOR_OWNER_SERVER_RID: int SECURITY_CREATOR_GROUP_SERVER_RID: int SECURITY_CREATOR_OWNER_RIGHTS_RID: int -SECURITY_NT_AUTHORITY = (0, 0, 0, 0, 0, 5) +SECURITY_NT_AUTHORITY: _SixIntTuple SECURITY_DIALUP_RID: int SECURITY_NETWORK_RID: int SECURITY_BATCH_RID: int @@ -98,7 +102,7 @@ DOMAIN_ALIAS_RID_CRYPTO_OPERATORS: int DOMAIN_ALIAS_RID_CACHEABLE_PRINCIPALS_GROUP: int DOMAIN_ALIAS_RID_NON_CACHEABLE_PRINCIPALS_GROUP: int DOMAIN_ALIAS_RID_EVENT_LOG_READERS_GROUP: int -SECURITY_MANDATORY_LABEL_AUTHORITY = (0, 0, 0, 0, 0, 16) +SECURITY_MANDATORY_LABEL_AUTHORITY: _SixIntTuple SECURITY_MANDATORY_UNTRUSTED_RID: int SECURITY_MANDATORY_LOW_RID: int SECURITY_MANDATORY_MEDIUM_RID: int @@ -106,11 +110,11 @@ SECURITY_MANDATORY_HIGH_RID: int SECURITY_MANDATORY_SYSTEM_RID: int SECURITY_MANDATORY_PROTECTED_PROCESS_RID: int SECURITY_MANDATORY_MAXIMUM_USER_RID: int -SYSTEM_LUID = (999, 0) -ANONYMOUS_LOGON_LUID = (998, 0) -LOCALSERVICE_LUID = (997, 0) -NETWORKSERVICE_LUID = (996, 0) -IUSER_LUID = (995, 0) +SYSTEM_LUID: tuple[int, int] +ANONYMOUS_LOGON_LUID: tuple[int, int] +LOCALSERVICE_LUID: tuple[int, int] +NETWORKSERVICE_LUID: tuple[int, int] +IUSER_LUID: tuple[int, int] SE_GROUP_MANDATORY: int SE_GROUP_ENABLED_BY_DEFAULT: int SE_GROUP_ENABLED: int diff --git a/stubs/tensorflow/tensorflow/__init__.pyi b/stubs/tensorflow/tensorflow/__init__.pyi index 07690becdd72..eae7b85a7cdf 100644 --- a/stubs/tensorflow/tensorflow/__init__.pyi +++ b/stubs/tensorflow/tensorflow/__init__.pyi @@ -109,8 +109,8 @@ class Variable(Tensor, metaclass=_VariableMetaclass): dtype: _DTypeLike | None = None, import_scope: str | None = None, constraint: Callable[[Tensor], Tensor] | None = None, - synchronization: VariableSynchronization = VariableSynchronization.AUTO, - aggregation: VariableAggregation = VariableAggregation.NONE, + synchronization: VariableSynchronization = ..., + aggregation: VariableAggregation = ..., shape: _ShapeLike | None = None, experimental_enable_variable_lifting: _bool = True, ) -> None: ... @@ -121,9 +121,7 @@ class RaggedTensor(metaclass=ABCMeta): self, axis: _TensorCompatible | None = None, name: str | None = None, out_type: _DTypeLike | None = None ) -> Tensor: ... @classmethod - def from_sparse( - cls, st_input: SparseTensor, name: str | None = None, row_splits_dtype: _DTypeLike = int64 - ) -> RaggedTensor: ... + def from_sparse(cls, st_input: SparseTensor, name: str | None = None, row_splits_dtype: _DTypeLike = ...) -> RaggedTensor: ... def to_sparse(self, name: str | None = None) -> SparseTensor: ... def to_tensor( self, default_value: float | str | None = None, name: str | None = None, shape: _ShapeLike | None = None