From 9c706558c8562b40b7df3f673bfdf6e5275db41a Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Fri, 20 May 2022 19:05:31 +0300 Subject: [PATCH] Drop support for EOL Python 2.7, 3.5-3.6 (#191) --- run_tests.py | 3 +- setup.cfg | 3 -- setup.py | 7 +++- src/pep8ext_naming.py | 58 +++++++++++++---------------- testsuite/N801.py | 30 ++++++++++++--- testsuite/N801_py3.py | 19 ---------- testsuite/N802.py | 28 +++++++++++--- testsuite/N802_py3.py | 7 ---- testsuite/N802_py35.py | 9 ----- testsuite/N803.py | 40 +++++++++++++++++++- testsuite/N803_py2.py | 7 ---- testsuite/N803_py3.py | 31 --------------- testsuite/N803_py35.py | 7 ---- testsuite/N804.py | 47 ++++++++++++++++++++--- testsuite/N804_py35.py | 37 ------------------ testsuite/N805.py | 54 +++++++++++++++++---------- testsuite/N805_py35.py | 16 -------- testsuite/N806.py | 48 +++++++++++++++++++++++- testsuite/N806_py2.py | 31 --------------- testsuite/N806_py3.py | 36 ------------------ testsuite/N806_py35.py | 8 ---- testsuite/N807.py | 39 ++++++++++++++++++- testsuite/N807_py3.py | 21 ----------- testsuite/N807_py35.py | 14 ------- testsuite/N816.py | 29 +++++++++++++++ testsuite/N816_py3.py | 17 --------- testsuite/N816_py37.py | 13 ------- testsuite/N81x.py | 10 +++++ testsuite/N81x_py3.py | 11 ------ testsuite/{N8xx_py36.py => N8xx.py} | 5 +-- 30 files changed, 317 insertions(+), 368 deletions(-) delete mode 100644 testsuite/N801_py3.py delete mode 100644 testsuite/N802_py3.py delete mode 100644 testsuite/N802_py35.py delete mode 100644 testsuite/N803_py2.py delete mode 100644 testsuite/N803_py3.py delete mode 100644 testsuite/N803_py35.py delete mode 100644 testsuite/N804_py35.py delete mode 100644 testsuite/N805_py35.py delete mode 100644 testsuite/N806_py2.py delete mode 100644 testsuite/N806_py3.py delete mode 100644 testsuite/N806_py35.py delete mode 100644 testsuite/N807_py3.py delete mode 100644 testsuite/N807_py35.py delete mode 100644 testsuite/N816_py3.py delete mode 100644 testsuite/N816_py37.py delete mode 100644 testsuite/N81x_py3.py rename testsuite/{N8xx_py36.py => N8xx.py} (75%) diff --git a/run_tests.py b/run_tests.py index 660fede..4d46afa 100644 --- a/run_tests.py +++ b/run_tests.py @@ -1,4 +1,3 @@ -import io import optparse import os import platform @@ -25,7 +24,7 @@ def main(): errors = 0 for filename in os.listdir('testsuite'): filepath = os.path.join('testsuite', filename) - with io.open(filepath, encoding='utf8') as fd: + with open(filepath, encoding='utf8') as fd: lines = list(fd) if not is_test_allowed(lines): continue diff --git a/setup.cfg b/setup.cfg index c65b848..ae3d480 100644 --- a/setup.cfg +++ b/setup.cfg @@ -3,6 +3,3 @@ project_urls = Source=https://github.com/PyCQA/pep8-naming Issues=https://github.com/PyCQA/pep8-naming/issues Changelog=https://github.com/PyCQA/pep8-naming/blob/main/CHANGELOG.rst - -[wheel] -universal = 1 diff --git a/setup.py b/setup.py index d099e4e..7e87910 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import with_statement from setuptools import setup from setuptools.command.test import test as TestCommand @@ -60,6 +58,11 @@ def run_tests(self): 'Operating System :: OS Independent', 'Programming Language :: Python', 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3 :: Only', 'Topic :: Software Development :: Libraries :: Python Modules', 'Topic :: Software Development :: Quality Assurance', ], diff --git a/src/pep8ext_naming.py b/src/pep8ext_naming.py index b389914..6a3bb06 100644 --- a/src/pep8ext_naming.py +++ b/src/pep8ext_naming.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """Checker of PEP-8 Naming Conventions.""" import sys from collections import deque @@ -27,12 +26,16 @@ METACLASS_BASES = frozenset(('type', 'ABCMeta')) # Node types which may contain class methods -METHOD_CONTAINER_NODES = {ast.If, ast.While, ast.For, ast.With, ast.Try} -FUNC_NODES = (ast.FunctionDef,) - -if PYTHON_VERSION > (3, 5): - FUNC_NODES += (ast.AsyncFunctionDef,) - METHOD_CONTAINER_NODES |= {ast.AsyncWith, ast.AsyncFor} +METHOD_CONTAINER_NODES = { + ast.If, + ast.While, + ast.For, + ast.With, + ast.Try, + ast.AsyncWith, + ast.AsyncFor, +} +FUNC_NODES = (ast.FunctionDef, ast.AsyncFunctionDef) if PYTHON_VERSION < (3, 8): def get_arg_name_tuples(node): @@ -66,7 +69,7 @@ def _err(self, node, code, **kwargs): code_str = getattr(self, code) if kwargs: code_str = code_str.format(**kwargs) - return lineno, col_offset + 1, '%s %s' % (code, code_str), self + return lineno, col_offset + 1, f'{code} {code_str}', self def _ignored(name, ignore): @@ -77,7 +80,7 @@ def _ignored(name, ignore): {'__doc__': "Base for AST Checks.", 'err': _err}) -class _FunctionType(object): +class _FunctionType: CLASSMETHOD = 'classmethod' STATICMETHOD = 'staticmethod' FUNCTION = 'function' @@ -110,7 +113,7 @@ def _build_decorator_to_type(classmethod_decorators, staticmethod_decorators): return decorator_to_type -class NamingChecker(object): +class NamingChecker: """Checker of PEP-8 Naming Conventions.""" name = 'naming' version = __version__ @@ -175,12 +178,10 @@ def run(self): return self.visit_tree(self._node) if self._node else () def visit_tree(self, node): - for error in self.visit_node(node): - yield error + yield from self.visit_node(node) self.parents.append(node) for child in iter_child_nodes(node): - for error in self.visit_tree(child): - yield error + yield from self.visit_tree(child) self.parents.pop() def visit_node(self, node): @@ -196,8 +197,7 @@ def visit_node(self, node): visitor_method = getattr(visitor, method, None) if visitor_method is None: continue - for error in visitor_method(node, parents, ignore_names): - yield error + yield from visitor_method(node, parents, ignore_names) def tag_class_functions(self, cls_node): """Tag functions if they are methods, classmethods, staticmethods""" @@ -458,40 +458,34 @@ def visit_assign(self, node, parents, ignore=None): if self.is_namedtupe(node.value): return for target in node.targets: - for error in self._find_errors(target, parents, ignore): - yield error + yield from self._find_errors(target, parents, ignore) def visit_namedexpr(self, node, parents, ignore): if self.is_namedtupe(node.value): return - for error in self._find_errors(node.target, parents, ignore): - yield error + yield from self._find_errors(node.target, parents, ignore) visit_annassign = visit_namedexpr def visit_with(self, node, parents, ignore): for item in node.items: - for error in self._find_errors( - item.optional_vars, parents, ignore): - yield error + yield from self._find_errors( + item.optional_vars, parents, ignore) visit_asyncwith = visit_with def visit_for(self, node, parents, ignore): - for error in self._find_errors(node.target, parents, ignore): - yield error + yield from self._find_errors(node.target, parents, ignore) visit_asyncfor = visit_for def visit_excepthandler(self, node, parents, ignore): if node.name: - for error in self._find_errors(node, parents, ignore): - yield error + yield from self._find_errors(node, parents, ignore) def visit_generatorexp(self, node, parents, ignore): for gen in node.generators: - for error in self._find_errors(gen.target, parents, ignore): - yield error + yield from self._find_errors(gen.target, parents, ignore) visit_listcomp = visit_dictcomp = visit_setcomp = visit_generatorexp @@ -525,11 +519,9 @@ def _extract_names(assignment_target): if element_type is ast.Name: yield element.id elif element_type in (ast.Tuple, ast.List): - for n in _extract_names(element): - yield n + yield from _extract_names(element) elif element_type is ast.Starred: # PEP 3132 - for n in _extract_names(element.value): - yield n + yield from _extract_names(element.value) elif target_type is ast.ExceptHandler: yield assignment_target.name diff --git a/testsuite/N801.py b/testsuite/N801.py index 0653f6b..74046e5 100644 --- a/testsuite/N801.py +++ b/testsuite/N801.py @@ -1,19 +1,19 @@ #: N801 -class notok(object): +class notok: pass #: Okay(--ignore-names=notok) -class notok(object): +class notok: pass #: Okay(--ignore-names=*ok) -class notok(object): +class notok: pass #: N801 -class Good(object): - class notok(object): +class Good: + class notok: pass pass #: Okay -class VeryGood(object): +class VeryGood: pass #: N801:1:7 class _: @@ -52,3 +52,21 @@ class MEH__: #: Okay class __MEH__: pass +#: Okay +class Γ: + pass +#: Okay +class ΓγΓγ: + pass +#: Okay +class ΓγΓ6: + pass +#: Okay +class _Γ: + pass +#: N801:1:7 +class γ: + pass +#: N801 +class _γ: + pass diff --git a/testsuite/N801_py3.py b/testsuite/N801_py3.py deleted file mode 100644 index cba702e..0000000 --- a/testsuite/N801_py3.py +++ /dev/null @@ -1,19 +0,0 @@ -# python_version >= '3' -#: Okay -class Γ: - pass -#: Okay -class ΓγΓγ: - pass -#: Okay -class ΓγΓ6: - pass -#: Okay -class _Γ: - pass -#: N801:1:7 -class γ: - pass -#: N801 -class _γ: - pass diff --git a/testsuite/N802.py b/testsuite/N802.py index 9bf09be..c36ef65 100644 --- a/testsuite/N802.py +++ b/testsuite/N802.py @@ -29,27 +29,27 @@ def NotOK(): def _(): pass #: Okay -class Foo(object): +class Foo: def __method(self): pass #: Okay -class Foo(object): +class Foo: def __method__(self): pass #: Okay -class ClassName(object): +class ClassName: def __method__(self): pass #: N802 -class ClassName(object): +class ClassName: def notOk(self): pass #: Okay(--ignore-names=notOk) -class ClassName(object): +class ClassName: def notOk(self): pass #: Okay(--ignore-names=*Ok) -class ClassName(object): +class ClassName: def notOk(self): pass #: Okay @@ -84,3 +84,19 @@ def asyncTearDown(self): pass def setUpTestData(self): pass + +#: Okay +def γ(x): + pass +#: Okay +def γ6(x): + pass + +#: Okay +async def func(param1, param2): + do_stuff() + await some_coroutine() +#: N802 +async def Func(param1, param2): + do_stuff() + await some_coroutine() diff --git a/testsuite/N802_py3.py b/testsuite/N802_py3.py deleted file mode 100644 index 7b5d0b0..0000000 --- a/testsuite/N802_py3.py +++ /dev/null @@ -1,7 +0,0 @@ -# python_version >= '3' -#: Okay -def γ(x): - pass -#: Okay -def γ6(x): - pass diff --git a/testsuite/N802_py35.py b/testsuite/N802_py35.py deleted file mode 100644 index 8a0a782..0000000 --- a/testsuite/N802_py35.py +++ /dev/null @@ -1,9 +0,0 @@ -# python_version >= '3.5' -#: Okay -async def func(param1, param2): - do_stuff() - await some_coroutine() -#: N802 -async def Func(param1, param2): - do_stuff() - await some_coroutine() diff --git a/testsuite/N803.py b/testsuite/N803.py index 7f96d4b..1a7a771 100644 --- a/testsuite/N803.py +++ b/testsuite/N803.py @@ -59,7 +59,7 @@ def b18(a, *_): def b19(a, **_): pass #: N803:2:24 -class Test(object): +class Test: def __init__(self, BAD): pass @@ -75,3 +75,41 @@ def f(*I): #: Okay(--ignore-names=I) def f(*I): I[''].think_therefore_i_am + +#: Okay +def compare(a, b, *, key=None): + pass +#: N803 +def compare(a, b, *, BAD=None): + pass +#: N803 +def compare(a, b, *VERY, bad=None): + pass +#: N803 +def compare(a, b, *ok, fine=None, **BAD): + pass +#: Okay +def foo(α, ß, γ): + pass +#: Okay +def foo(α, ß=''): + pass +#: Okay +def foo(**κ): + pass +#: Okay +def foo(*α): + pass +#: Okay +def foo(**κ2): + pass +#: Okay +def foo(*α2): + pass + +#: Okay +async def compare(a, b, *, key=None): + pass +#: N803 +async def compare(a, b, *, BAD=None): + pass diff --git a/testsuite/N803_py2.py b/testsuite/N803_py2.py deleted file mode 100644 index fe9972e..0000000 --- a/testsuite/N803_py2.py +++ /dev/null @@ -1,7 +0,0 @@ -# python_version < '3' -#: Okay -def test(a, b, (good, verygood)): - pass -#: N803 -def bad(a, b, (OHH, NOO)): - pass diff --git a/testsuite/N803_py3.py b/testsuite/N803_py3.py deleted file mode 100644 index cc8f325..0000000 --- a/testsuite/N803_py3.py +++ /dev/null @@ -1,31 +0,0 @@ -# python_version >= '3' -#: Okay -def compare(a, b, *, key=None): - pass -#: N803 -def compare(a, b, *, BAD=None): - pass -#: N803 -def compare(a, b, *VERY, bad=None): - pass -#: N803 -def compare(a, b, *ok, fine=None, **BAD): - pass -#: Okay -def foo(α, ß, γ): - pass -#: Okay -def foo(α, ß=''): - pass -#: Okay -def foo(**κ): - pass -#: Okay -def foo(*α): - pass -#: Okay -def foo(**κ2): - pass -#: Okay -def foo(*α2): - pass diff --git a/testsuite/N803_py35.py b/testsuite/N803_py35.py deleted file mode 100644 index 8cf0651..0000000 --- a/testsuite/N803_py35.py +++ /dev/null @@ -1,7 +0,0 @@ -# python_version >= '3.5' -#: Okay -async def compare(a, b, *, key=None): - pass -#: N803 -async def compare(a, b, *, BAD=None): - pass diff --git a/testsuite/N804.py b/testsuite/N804.py index 1d826ee..090c0e8 100644 --- a/testsuite/N804.py +++ b/testsuite/N804.py @@ -1,7 +1,7 @@ from abc import ABCMeta #: N804:7:13 -class Foo(object): +class Foo: @classmethod def mmm(cls, ads): pass @@ -17,17 +17,17 @@ def test(self, ads): def __init_subclass(self, ads): pass #: Okay(--ignore-names=klass) -class SpecialConventionCase(object): +class SpecialConventionCase: @classmethod def prepare_meta(klass, root): pass #: Okay(--ignore-names=_*) -class SpecialConventionCase(object): +class SpecialConventionCase: @classmethod def prepare_meta(_class, root): pass #: N804:3:14(--classmethod-decorators=clazzy,cool) -class NewClassIsRequired(object): +class NewClassIsRequired: @cool def test(self, sy): pass @@ -43,7 +43,44 @@ class MetaMethod(ABCMeta): def test(cls): pass #: Okay -class NotMeta(object): +class NotMeta: + otherclass = Foo +class AttributeParent(NotMeta.otherclass): + pass +class CallParent(type('_tmp', (), {})): + pass + +#: N804:7:19 +class Foo: + @classmethod + async def mmm(cls, ads): + pass + + @classmethod + async def bad(self, ads): + pass + + @calling() + async def test(self, ads): + pass + + async def __init_subclass(self, ads): + pass +#: N804:3:20(--classmethod-decorators=clazzy,cool) +class NewClassIsRequired: + @cool + async def test(self, sy): + pass +#: N804 +class Meta(type): + async def __new__(self, name, bases, attrs): + pass +#: Okay +class MetaMethod(type): + async def test(cls): + pass +#: Okay +class NotMeta: otherclass = Foo class AttributeParent(NotMeta.otherclass): pass diff --git a/testsuite/N804_py35.py b/testsuite/N804_py35.py deleted file mode 100644 index 8cd6e12..0000000 --- a/testsuite/N804_py35.py +++ /dev/null @@ -1,37 +0,0 @@ -# python_version >= '3.5' -#: N804:7:19 -class Foo(object): - @classmethod - async def mmm(cls, ads): - pass - - @classmethod - async def bad(self, ads): - pass - - @calling() - async def test(self, ads): - pass - - async def __init_subclass(self, ads): - pass -#: N804:3:20(--classmethod-decorators=clazzy,cool) -class NewClassIsRequired(object): - @cool - async def test(self, sy): - pass -#: N804 -class Meta(type): - async def __new__(self, name, bases, attrs): - pass -#: Okay -class MetaMethod(type): - async def test(cls): - pass -#: Okay -class NotMeta(object): - otherclass = Foo -class AttributeParent(NotMeta.otherclass): - pass -class CallParent(type('_tmp', (), {})): - pass diff --git a/testsuite/N805.py b/testsuite/N805.py index 32ed295..1fabb4b 100644 --- a/testsuite/N805.py +++ b/testsuite/N805.py @@ -12,26 +12,26 @@ class C: def m(cls, k='w'): # noqa: N805 pass #: N805 -class Foo(object): +class Foo: def good(self, ads): pass def bad(ads, self): pass #: Okay(--ignore-names=a*) -class Foo(object): +class Foo: def bad(ads, self): pass #: Okay(--ignore-names=source) -class GraphQLNode(object): +class GraphQLNode: def resolve_foo(source, info): pass #: Okay -class Foo(object): +class Foo: def __new__(cls): return object.__new__(Foo) #: Okay -class Foo(object): +class Foo: @classmethod def __prepare__(cls): pass @@ -48,15 +48,15 @@ def test2(so, exciting): pass test2 = staticmethod(test2) #: Okay -class Foo(object): +class Foo: def __new__(cls): pass #: Okay -class Foo(object): +class Foo: def __init_subclass__(cls): pass #: Okay -class Foo(object): +class Foo: def __class_getitem__(cls, key): pass #: Okay @@ -78,7 +78,7 @@ def __new__(cls, name, bases, attrs): def test(cls): pass #: Okay(--classmethod-decorators=clazzy,cool) -class NewClassmethodDecorators(object): +class NewClassmethodDecorators: @clazzy def test1(cls, sy): pass @@ -95,22 +95,22 @@ def test4(cls, sy): pass test4 = cool(test4) #: N805(--classmethod-decorators=clazzy,cool) -class ButWeLostTheOriginalClassMethodDecorator(object): +class ButWeLostTheOriginalClassMethodDecorator: @classmethod def test(cls, sy): pass #: N805(--classmethod-decorators=clazzy,cool) -class ButWeLostTheOriginalClassMethodLateDecorator(object): +class ButWeLostTheOriginalClassMethodLateDecorator: def test(cls, sy): pass test = classmethod(test) #: Okay(--classmethod-decorators=myclassmethod) -class C(object): +class C: @myclassmethod('foo') def bar(cls): return 42 #: Okay -class PropertySetter(object): +class PropertySetter: @property def var(self): return True @@ -118,22 +118,22 @@ def var(self): def var(self, value): self.var = value #: Okay -class CalledInstanceDecorator(object): +class CalledInstanceDecorator: @module.inner.decorator() def test(self): pass #: Okay(--classmethod-decorators=decorator) -class CalledClassDecorator(object): +class CalledClassDecorator: @module.inner.decorator() def test(cls): pass #: Okay(--staticmethod-decorators=decorator) -class CalledStaticDecorator(object): +class CalledStaticDecorator: @module.inner.decorator() def test(): pass #: Okay(--staticmethod-decorators=ecstatik,stcmthd) -class NewStaticMethodDecorators(object): +class NewStaticMethodDecorators: @ecstatik def test1(so, exciting): pass @@ -150,12 +150,28 @@ def test4(so, exciting): pass test4 = stcmthd(test4) #: N805(--staticmethod-decorators=exstatik,stcmthd) -class ButWeLostTheOriginalStaticMethodDecorator(object): +class ButWeLostTheOriginalStaticMethodDecorator: @staticmethod def test(so, exciting): pass #: N805(--staticmethod-decorators=exstatik,stcmthd) -class ButWeLostTheOriginalStaticMethodLateDecorator(object): +class ButWeLostTheOriginalStaticMethodLateDecorator: def test(so, exciting): pass test = staticmethod(test) + +#: Okay +class C: + async def __init__(*args, **kwargs): + pass +#: N805:4:17 +class C: + @decorator( + 'a') + async def m(cls, k='w'): # noqa: N805 + pass +#: N805(--staticmethod-decorators=exstatik,stcmthd) +class ButWeLostTheOriginalStaticMethodLateDecorator: + async def test(so, exciting): + pass + test = staticmethod(test) diff --git a/testsuite/N805_py35.py b/testsuite/N805_py35.py deleted file mode 100644 index 3f86f2f..0000000 --- a/testsuite/N805_py35.py +++ /dev/null @@ -1,16 +0,0 @@ -# python_version >= '3.5' -#: Okay -class C: - async def __init__(*args, **kwargs): - pass -#: N805:4:17 -class C: - @decorator( - 'a') - async def m(cls, k='w'): # noqa: N805 - pass -#: N805(--staticmethod-decorators=exstatik,stcmthd) -class ButWeLostTheOriginalStaticMethodLateDecorator(object): - async def test(so, exciting): - pass - test = staticmethod(test) diff --git a/testsuite/N806.py b/testsuite/N806.py index 88bae3a..51969cb 100644 --- a/testsuite/N806.py +++ b/testsuite/N806.py @@ -8,7 +8,7 @@ def test2(): #: Okay GOOD = 1 #: Okay -class Test(object): +class Test: GOOD = 1 #: N806 def test(): @@ -19,7 +19,7 @@ def test(): #: N806 def test(): def test2(): - class Foo(object): + class Foo: def test3(self): Bad = 3 #: Okay(--ignore-names=Bad) @@ -175,3 +175,47 @@ def n(): #: N806:2:26 def e(): return tuple(BaD for BaD in range(2)) + +#: Okay +VAR1, *VAR2, VAR3 = 1, 2, 3 +#: Okay +Α, *Β, Γ = 1, 2, 3 +#: Okay +[VAR1, *VAR2, VAR3] = (1, 2, 3) +#: N806 +def extended_unpacking_not_ok(): + Var1, *Var2, Var3 = 1, 2, 3 +#: N806 +def extended_unpacking_not_ok(): + [Var1, *Var2, Var3] = (1, 2, 3) +#: Okay +def assing_to_unpack_ok(): + a, *[b] = 1, 2 +#: N806 +def assing_to_unpack_not_ok(): + a, *[bB] = 1, 2 +#: Okay +Γ = 1 +#: N806 +def f(): + Δ = 1 +#: N806 +def f(): + _Δ = 1 +#: Okay +def f(): + γ = 1 +#: Okay +def f(): + _γ = 1 +#: Okay +def f(): + h, _, γ = s.partition('sep') + +#: Okay +async def test(): + good = 1 +#: N806 +async def f(): + async with expr as ASYNC_VAR: + pass diff --git a/testsuite/N806_py2.py b/testsuite/N806_py2.py deleted file mode 100644 index ac43204..0000000 --- a/testsuite/N806_py2.py +++ /dev/null @@ -1,31 +0,0 @@ -# python_version < '3' -#: Okay -def f(): - try: - f() - except (A, B) as (a, b): - pass -#: Okay -def f(): - try: - f() - except X, foo: - pass -#: N806 -def f(): - try: - f() - except (A, B) as (good, BAD): - pass -#: Okay -def f(): - try: - f() - except X, foo.bar: - pass -#: N806 -def f(): - try: - f() - except mod.Timeout, mod.ConnectionError: - pass diff --git a/testsuite/N806_py3.py b/testsuite/N806_py3.py deleted file mode 100644 index 85c630e..0000000 --- a/testsuite/N806_py3.py +++ /dev/null @@ -1,36 +0,0 @@ -# python_version >= '3' -#: Okay -VAR1, *VAR2, VAR3 = 1, 2, 3 -#: Okay -Α, *Β, Γ = 1, 2, 3 -#: Okay -[VAR1, *VAR2, VAR3] = (1, 2, 3) -#: N806 -def extended_unpacking_not_ok(): - Var1, *Var2, Var3 = 1, 2, 3 -#: N806 -def extended_unpacking_not_ok(): - [Var1, *Var2, Var3] = (1, 2, 3) -#: Okay -def assing_to_unpack_ok(): - a, *[b] = 1, 2 -#: N806 -def assing_to_unpack_not_ok(): - a, *[bB] = 1, 2 -#: Okay -Γ = 1 -#: N806 -def f(): - Δ = 1 -#: N806 -def f(): - _Δ = 1 -#: Okay -def f(): - γ = 1 -#: Okay -def f(): - _γ = 1 -#: Okay -def f(): - h, _, γ = s.partition('sep') diff --git a/testsuite/N806_py35.py b/testsuite/N806_py35.py deleted file mode 100644 index 2228853..0000000 --- a/testsuite/N806_py35.py +++ /dev/null @@ -1,8 +0,0 @@ -# python_version >= '3.5' -#: Okay -async def test(): - good = 1 -#: N806 -async def f(): - async with expr as ASYNC_VAR: - pass diff --git a/testsuite/N807.py b/testsuite/N807.py index 8d75906..8d79196 100644 --- a/testsuite/N807.py +++ b/testsuite/N807.py @@ -37,12 +37,12 @@ def bad__(): def __bad__(): pass #: Okay -class ClassName(object): +class ClassName: def method(self): def __bad(): pass #: N807 -class ClassName(object): +class ClassName: def method(self): def __bad__(): pass @@ -58,3 +58,38 @@ def __dir__(): #: Okay def __getattr__(name): pass + +#: Okay +class C: + def γ(self): + pass +#: Okay +def __β(self): + pass +#: Okay +def β__(self): + pass +#: N807 +def __β__(self): + pass +#: N807 +def __β6__(self): + pass +#: Okay +class C: + def γ1(self): + pass + +#: Okay +class C: + async def γ(self): + pass +#: Okay +async def __β(self): + pass +#: Okay +async def β__(self): + pass +#: N807 +async def __β__(self): + pass diff --git a/testsuite/N807_py3.py b/testsuite/N807_py3.py deleted file mode 100644 index 6a16b9e..0000000 --- a/testsuite/N807_py3.py +++ /dev/null @@ -1,21 +0,0 @@ -# python_version >= '3' -#: Okay -class C: - def γ(self): - pass -#: Okay -def __β(self): - pass -#: Okay -def β__(self): - pass -#: N807 -def __β__(self): - pass -#: N807 -def __β6__(self): - pass -#: Okay -class C: - def γ1(self): - pass diff --git a/testsuite/N807_py35.py b/testsuite/N807_py35.py deleted file mode 100644 index 570a107..0000000 --- a/testsuite/N807_py35.py +++ /dev/null @@ -1,14 +0,0 @@ -# python_version >= '3.5' -#: Okay -class C: - async def γ(self): - pass -#: Okay -async def __β(self): - pass -#: Okay -async def β__(self): - pass -#: N807 -async def __β__(self): - pass diff --git a/testsuite/N816.py b/testsuite/N816.py index ea62bdd..36f6523 100644 --- a/testsuite/N816.py +++ b/testsuite/N816.py @@ -22,3 +22,32 @@ mixedCase = 0 #: Okay(--ignore-names=*Case) mixedCase = 0 +#: Okay +Γ = 1 +#: N816 +γΓ = 1 +#: Okay +Γ1 = 1 +#: Okay +Γ_ = 1 +#: Okay +Γ_1 = 1 +#: Okay +Γ1_ = 1 +#: N816 +γΓ1 = 1 +#: N816 +_γ1Γ = 1 + +#: Okay +async with expr as Γ: + pass +#: N816 +async with expr as γΓ: + pass +#: Okay +async for Γ1 in iterator: + pass +#: N816 +async for γΓ1 in iterator: + pass diff --git a/testsuite/N816_py3.py b/testsuite/N816_py3.py deleted file mode 100644 index b4f503b..0000000 --- a/testsuite/N816_py3.py +++ /dev/null @@ -1,17 +0,0 @@ -# python_version >= '3' -#: Okay -Γ = 1 -#: N816 -γΓ = 1 -#: Okay -Γ1 = 1 -#: Okay -Γ_ = 1 -#: Okay -Γ_1 = 1 -#: Okay -Γ1_ = 1 -#: N816 -γΓ1 = 1 -#: N816 -_γ1Γ = 1 diff --git a/testsuite/N816_py37.py b/testsuite/N816_py37.py deleted file mode 100644 index 9584eda..0000000 --- a/testsuite/N816_py37.py +++ /dev/null @@ -1,13 +0,0 @@ -# python_version >= '3.7' -#: Okay -async with expr as Γ: - pass -#: N816 -async with expr as γΓ: - pass -#: Okay -async for Γ1 in iterator: - pass -#: N816 -async for γΓ1 in iterator: - pass diff --git a/testsuite/N81x.py b/testsuite/N81x.py index 2870ba1..108d857 100644 --- a/testsuite/N81x.py +++ b/testsuite/N81x.py @@ -18,3 +18,13 @@ from mod import CamelCase as CONSTANT #: N817:1:1 from mod import CamelCase as CC +#: Okay +import good as γ +#: Okay +from mod import good as γ +#: Okay +import GOOD as Γ +#: Okay +from mod import GOOD as Γ +#: Okay +from mod import GOOD as Γ1 diff --git a/testsuite/N81x_py3.py b/testsuite/N81x_py3.py deleted file mode 100644 index a1fa52a..0000000 --- a/testsuite/N81x_py3.py +++ /dev/null @@ -1,11 +0,0 @@ -# python_version >= '3' -#: Okay -import good as γ -#: Okay -from mod import good as γ -#: Okay -import GOOD as Γ -#: Okay -from mod import GOOD as Γ -#: Okay -from mod import GOOD as Γ1 diff --git a/testsuite/N8xx_py36.py b/testsuite/N8xx.py similarity index 75% rename from testsuite/N8xx_py36.py rename to testsuite/N8xx.py index cc9008b..090042b 100644 --- a/testsuite/N8xx_py36.py +++ b/testsuite/N8xx.py @@ -1,10 +1,9 @@ -# python_version >= '3.6' #: Okay var1: int = 1 var2: int def some(): variable: int = 1 -class Test(object): +class Test: variable: int = 1 #: N816:1:1 mixedCase: int = 1 @@ -12,5 +11,5 @@ class Test(object): def some(): mixedCase: int = 1 #: N815:2:5 -class Test(object): +class Test: mixedCase: int = 1