mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
[lint] upgrade mypy to latest version
Fixes https://github.com/pytorch/pytorch/issues/75927. Had to fix some bugs and add some ignores. To check if clean: ``` lintrunner --paths-cmd='git grep -Il .' --take MYPY,MYPYSTRICT ``` Pull Request resolved: https://github.com/pytorch/pytorch/pull/76753 Approved by: https://github.com/malfet
This commit is contained in:
committed by
PyTorch MergeBot
parent
8473173c36
commit
fb0f285638
@ -537,9 +537,8 @@ class StmtBuilder(Builder):
|
||||
raise UnsupportedNodeError(ctx, stmt, reason='without assigned value')
|
||||
|
||||
# Disallow type annotations on instance attributes outside of __init__
|
||||
if type(stmt.target) == ast.Attribute and\
|
||||
stmt.target.value.id == "self" and\
|
||||
ctx.funcname != "__init__":
|
||||
if type(stmt.target) == ast.Attribute and \
|
||||
stmt.target.value.id == "self" and ctx.funcname != "__init__": # type: ignore[attr-defined]
|
||||
start = stmt.col_offset
|
||||
end = start + len(f"self.{stmt.target.attr}")
|
||||
if hasattr(stmt.annotation, 'id'):
|
||||
|
Reference in New Issue
Block a user