-
Notifications
You must be signed in to change notification settings - Fork 229
Bump mypy to 1.16.0 #6858
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
Bump mypy to 1.16.0 #6858
Changes from all commits
78f5521
f99dda6
6673061
260d358
4454d04
7c9f776
6ad39d5
ee2e443
a175d9d
ad8a3a7
05df184
59edc1d
f8b2464
3734865
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 |
---|---|---|
|
@@ -355,11 +355,11 @@ | |
""" | ||
if ( | ||
not issubclass(node_class, ProcessNode) # type: ignore[redundant-expr] | ||
or not issubclass(node_class, FunctionCalculationMixin) # type: ignore[unreachable] | ||
or not issubclass(node_class, FunctionCalculationMixin) | ||
): | ||
raise TypeError('the node_class should be a sub class of `ProcessNode` and `FunctionCalculationMixin`') | ||
|
||
signature = inspect.signature(func) # type: ignore[unreachable] | ||
signature = inspect.signature(func) | ||
|
||
args: list[str] = [] | ||
var_positional: str | None = None | ||
|
@@ -373,17 +373,21 @@ | |
LOGGER.warning(f'function `{func.__name__}` has invalid type hints: {exception}') | ||
annotations = {} | ||
|
||
try: | ||
parsed_docstring = docstring_parser.parse(func.__doc__) | ||
except Exception as exception: | ||
LOGGER.warning(f'function `{func.__name__}` has a docstring that could not be parsed: {exception}') | ||
param_help_string = {} | ||
if func.__doc__ is None: | ||
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. This fixes:
Github is very confused, the diff here is actually not that bad, we're just handling the 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.
Yes, I think that is a bit too much, I won't throw warning for that. |
||
param_help_string: dict[str, str | None] = {} | ||
namespace_help_string = None | ||
else: | ||
param_help_string = {param.arg_name: param.description for param in parsed_docstring.params} | ||
namespace_help_string = parsed_docstring.short_description if parsed_docstring.short_description else '' | ||
if parsed_docstring.long_description is not None: | ||
namespace_help_string += f'\n\n{parsed_docstring.long_description}' | ||
try: | ||
parsed_docstring = docstring_parser.parse(func.__doc__) | ||
except Exception as exception: | ||
LOGGER.warning(f'function `{func.__name__}` has a docstring that could not be parsed: {exception}') | ||
param_help_string = {} | ||
namespace_help_string = None | ||
else: | ||
param_help_string = {param.arg_name: param.description for param in parsed_docstring.params} | ||
namespace_help_string = parsed_docstring.short_description if parsed_docstring.short_description else '' | ||
if parsed_docstring.long_description is not None: | ||
namespace_help_string += f'\n\n{parsed_docstring.long_description}' | ||
|
||
for key, parameter in signature.parameters.items(): | ||
if parameter.kind in [parameter.POSITIONAL_ONLY, parameter.POSITIONAL_OR_KEYWORD, parameter.KEYWORD_ONLY]: | ||
|
@@ -435,7 +439,7 @@ | |
def indirect_default(value=default): | ||
return to_aiida_type(value) | ||
else: | ||
indirect_default = default | ||
indirect_default = default # type: ignore[assignment] | ||
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. Not super clear how to solve this one, since
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 it can be anything then as error message suggest use 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 not sure what are you suggesting here? the callable type is inferred because 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. Okay, I misunderstood the change here. I think the mypy complain because the typechecker resolve the expression in if..else.. branch and want to make sure the type of expression conform with each other. Then the correct way to solve this might be for the else branch do: def indirect_default(value=default):
return lambda _: value (I am not sure this is correct, but I think it is better to just ignore the type error here to not touch the logic. so if you don't want to try please ignore my comment.) |
||
|
||
spec.input( | ||
parameter.name, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -231,7 +231,7 @@ def get_code_helper(cls, label, machinename=None, backend=None): | |
return result[0] | ||
|
||
@classmethod | ||
def get(cls, pk=None, label=None, machinename=None): | ||
def get(cls, pk=None, label=None, machinename=None): # type: ignore[override] | ||
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 don't understand why mypy complains here:
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. Since you asked, my answer is because we did bad design by keep on doing too much bad inheritance. |
||
"""Get a Computer object with given identifier string, that can either be | ||
the numeric ID (pk), or the label (and computername) (if unique). | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.