-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Use --strict
for selfcheck
#13464
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
Use --strict
for selfcheck
#13464
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -315,7 +315,7 @@ def _belongs_to_runtime(r: types.ModuleType, attr: str) -> bool: | |
except Exception: | ||
return False | ||
if obj_mod is not None: | ||
return obj_mod == r.__name__ | ||
return bool(obj_mod == r.__name__) | ||
return not isinstance(obj, types.ModuleType) | ||
|
||
runtime_public_contents = ( | ||
|
@@ -614,7 +614,7 @@ def get_type(arg: Any) -> str | None: | |
|
||
def has_default(arg: Any) -> bool: | ||
if isinstance(arg, inspect.Parameter): | ||
return arg.default != inspect.Parameter.empty | ||
return bool(arg.default != inspect.Parameter.empty) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am just curious: why There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
if isinstance(arg, nodes.Argument): | ||
return arg.kind.is_optional() | ||
raise AssertionError | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -869,7 +869,7 @@ def __init__( | |
|
||
def accept(self, visitor: TypeVisitor[T]) -> T: | ||
assert isinstance(visitor, SyntheticTypeVisitor) | ||
return visitor.visit_callable_argument(self) | ||
return cast(T, visitor.visit_callable_argument(self)) | ||
|
||
def serialize(self) -> JsonDict: | ||
assert False, "Synthetic types don't serialize" | ||
|
@@ -894,7 +894,7 @@ def __init__(self, items: list[Type], line: int = -1, column: int = -1) -> None: | |
|
||
def accept(self, visitor: TypeVisitor[T]) -> T: | ||
assert isinstance(visitor, SyntheticTypeVisitor) | ||
return visitor.visit_type_list(self) | ||
return cast(T, visitor.visit_type_list(self)) | ||
|
||
def serialize(self) -> JsonDict: | ||
assert False, "Synthetic types don't serialize" | ||
|
@@ -2365,7 +2365,7 @@ def simple_name(self) -> str: | |
|
||
def accept(self, visitor: TypeVisitor[T]) -> T: | ||
assert isinstance(visitor, SyntheticTypeVisitor) | ||
return visitor.visit_raw_expression_type(self) | ||
return cast(T, visitor.visit_raw_expression_type(self)) | ||
|
||
def serialize(self) -> JsonDict: | ||
assert False, "Synthetic types don't serialize" | ||
|
@@ -2488,7 +2488,7 @@ def __init__(self, type: Type, line: int = -1, column: int = -1) -> None: | |
|
||
def accept(self, visitor: TypeVisitor[T]) -> T: | ||
assert isinstance(visitor, SyntheticTypeVisitor) | ||
return visitor.visit_star_type(self) | ||
return cast(T, visitor.visit_star_type(self)) | ||
|
||
def serialize(self) -> JsonDict: | ||
assert False, "Synthetic types don't serialize" | ||
|
@@ -2630,7 +2630,7 @@ class EllipsisType(ProperType): | |
|
||
def accept(self, visitor: TypeVisitor[T]) -> T: | ||
assert isinstance(visitor, SyntheticTypeVisitor) | ||
return visitor.visit_ellipsis_type(self) | ||
return cast(T, visitor.visit_ellipsis_type(self)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How do you decide between There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would generally use But here, we can't use |
||
|
||
def serialize(self) -> JsonDict: | ||
assert False, "Synthetic types don't serialize" | ||
|
@@ -2739,7 +2739,7 @@ def __init__(self, fullname: str | None, args: list[Type], line: int) -> None: | |
|
||
def accept(self, visitor: TypeVisitor[T]) -> T: | ||
assert isinstance(visitor, SyntheticTypeVisitor) | ||
return visitor.visit_placeholder_type(self) | ||
return cast(T, visitor.visit_placeholder_type(self)) | ||
|
||
def serialize(self) -> str: | ||
# We should never get here since all placeholders should be replaced | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
__getattribute__
feels like it could be quite performance-sensitive, sotype: ignore
feels like the best option here imo.