Skip to content

Commit

Permalink
Remove Python 3.7 compatibility code
Browse files Browse the repository at this point in the history
  • Loading branch information
jparise committed Oct 22, 2023
1 parent 0e8f745 commit 0ddfcea
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions src/pep8ext_naming.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Checker of PEP-8 Naming Conventions."""
import ast
import sys
from ast import iter_child_nodes
from collections import deque
from fnmatch import fnmatchcase
Expand All @@ -11,8 +10,6 @@

__version__ = '0.13.3'

PYTHON_VERSION = sys.version_info[:3]

CLASS_METHODS = frozenset((
'__new__',
'__init_subclass__',
Expand All @@ -32,14 +29,10 @@
}
FUNC_NODES = (ast.FunctionDef, ast.AsyncFunctionDef)

if PYTHON_VERSION < (3, 8):
def get_arg_name_tuples(node):
groups = (node.args.args, node.args.kwonlyargs)
return [(arg, arg.arg) for args in groups for arg in args]
else:
def get_arg_name_tuples(node):
groups = (node.args.posonlyargs, node.args.args, node.args.kwonlyargs)
return [(arg, arg.arg) for args in groups for arg in args]

def get_arg_name_tuples(node):
groups = (node.args.posonlyargs, node.args.args, node.args.kwonlyargs)
return [(arg, arg.arg) for args in groups for arg in args]


class _ASTCheckMeta(type):
Expand All @@ -54,12 +47,8 @@ def __init__(cls, class_name, bases, namespace):
def _err(self, node, code, **kwargs):
lineno, col_offset = node.lineno, node.col_offset
if isinstance(node, ast.ClassDef):
if PYTHON_VERSION < (3, 8):
lineno += len(node.decorator_list)
col_offset += 6
elif isinstance(node, FUNC_NODES):
if PYTHON_VERSION < (3, 8):
lineno += len(node.decorator_list)
col_offset += 4
code_str = getattr(self, code)
if kwargs:
Expand Down

0 comments on commit 0ddfcea

Please sign in to comment.