Skip to content

Commit

Permalink
Revert "Merge pull request #545 from asottile/skip-staticmethod"
Browse files Browse the repository at this point in the history
This reverts commit 8768d42, reversing
changes made to a2f517f.
  • Loading branch information
asottile committed Sep 28, 2021
1 parent d950562 commit 9b8a728
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 29 deletions.
11 changes: 0 additions & 11 deletions pyupgrade/_plugins/legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from typing import List
from typing import Set
from typing import Tuple
from typing import Union

from tokenize_rt import Offset
from tokenize_rt import Token
Expand All @@ -26,7 +25,6 @@

FUNC_TYPES = (ast.Lambda, ast.FunctionDef, ast.AsyncFunctionDef)
NON_LAMBDA_FUNC_TYPES = (ast.FunctionDef, ast.AsyncFunctionDef)
NonLambdaFuncTypes_T = Union[ast.FunctionDef, ast.AsyncFunctionDef]


def _fix_yield(i: int, tokens: List[Token]) -> None:
Expand All @@ -46,14 +44,6 @@ def _is_simple_base(base: ast.AST) -> bool:
)


def _is_staticmethod_decorated(node: NonLambdaFuncTypes_T) -> bool:
for decorator in node.decorator_list:
if isinstance(decorator, ast.Name) and decorator.id == 'staticmethod':
return True
else:
return False


class Scope:
def __init__(self, node: ast.AST) -> None:
self.node = node
Expand Down Expand Up @@ -137,7 +127,6 @@ def visit_Call(self, node: ast.Call) -> None:
isinstance(self._scopes[-1].node, NON_LAMBDA_FUNC_TYPES) and
node.func.attr == self._scopes[-1].node.name and
node.func.attr != '__new__' and
not _is_staticmethod_decorated(self._scopes[-1].node) and
len(self._scopes[-1].node.args.args) >= 1 and
node.args[0].id == self._scopes[-1].node.args.args[0].arg and
# the function is an attribute of the contained class name
Expand Down
18 changes: 0 additions & 18 deletions tests/features/super_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,6 @@ def test_fix_super(s, expected):
' return tuple.__new__(cls, (arg,))\n',
id='super() does not work properly for __new__',
),
pytest.param(
'class C(B):\n'
' @staticmethod\n'
' def f(arg):\n'
' return B.f(arg)\n',
id='skip staticmethod',
),
),
)
def test_old_style_class_super_noop(s):
Expand All @@ -214,17 +207,6 @@ def test_old_style_class_super_noop(s):
' super().f()\n'
' super().f(arg, arg)\n',
),
pytest.param(
'class C(B):\n'
' @classmethod\n'
' def f(cls):\n'
' B.f(cls)\n',
'class C(B):\n'
' @classmethod\n'
' def f(cls):\n'
' super().f()\n',
id='@classmethod',
),
pytest.param(
'class C(B):\n'
' def f(self, a):\n'
Expand Down

0 comments on commit 9b8a728

Please sign in to comment.