Hello community, here is the log from the commit of package python-flake8-pyi for openSUSE:Factory checked in at 2018-12-10 12:29:27 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-flake8-pyi (Old) and /work/SRC/openSUSE:Factory/.python-flake8-pyi.new.19453 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-flake8-pyi" Mon Dec 10 12:29:27 2018 rev:2 rq:656429 version:18.3.1 Changes: -------- --- /work/SRC/openSUSE:Factory/python-flake8-pyi/python-flake8-pyi.changes 2018-10-23 20:42:41.360379518 +0200 +++ /work/SRC/openSUSE:Factory/.python-flake8-pyi.new.19453/python-flake8-pyi.changes 2018-12-10 12:29:27.554459752 +0100 @@ -1,0 +2,5 @@ +Sat Dec 8 21:23:56 UTC 2018 - Matej Cepl <[email protected]> + +- Use tarball from the master as of 2018-12-08 to test #16 + +------------------------------------------------------------------- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-flake8-pyi.spec ++++++ --- /var/tmp/diff_new_pack.SaB0Ic/_old 2018-12-10 12:29:27.958459348 +0100 +++ /var/tmp/diff_new_pack.SaB0Ic/_new 2018-12-10 12:29:27.962459343 +0100 @@ -12,20 +12,22 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# Please submit bugfixes or comments via https://bugs.opensuse.org/ +# + %define skip_python2 1 %{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-flake8-pyi Version: 18.3.1 Release: 0 -License: MIT Summary: A plugin for flake8 to enable linting .pyi files -Url: https://github.com/ambv/flake8-pyi +License: MIT Group: Development/Languages/Python +Url: https://github.com/ambv/flake8-pyi Source: https://files.pythonhosted.org/packages/source/f/flake8-pyi/flake8-pyi-%{version}.tar.gz -BuildRequires: python-rpm-macros BuildRequires: %{python_module setuptools} +BuildRequires: python-rpm-macros # SECTION test requirements BuildRequires: %{python_module attrs} BuildRequires: %{python_module flake8 >= 3.2.1} @@ -54,13 +56,11 @@ %python_install %fdupes %{buildroot}%{python3_sitelib} - %check # https://github.com/ambv/flake8-pyi/issues/16 exc_tests="test_defaults or test_function_def" PYTHONPATH=%{buildroot}%{python3_sitelib} py.test3 -v -k "not ($exc_tests)" tests - %files %{python_files} %doc README.rst %{python3_sitelib}/* ++++++ flake8-pyi-18.3.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/flake8-pyi-18.3.1/.flake8 new/flake8-pyi-18.3.1/.flake8 --- old/flake8-pyi-18.3.1/.flake8 1970-01-01 01:00:00.000000000 +0100 +++ new/flake8-pyi-18.3.1/.flake8 2018-12-08 22:22:09.000000000 +0100 @@ -0,0 +1,7 @@ +# This is an example .flake8 config, used when developing flake8-pyi itself. + +[flake8] +ignore = E302, E501, E701, W503 +max-line-length = 80 +max-complexity = 12 +select = B,C,E,F,W,Y,B9 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/flake8-pyi-18.3.1/MANIFEST.in new/flake8-pyi-18.3.1/MANIFEST.in --- old/flake8-pyi-18.3.1/MANIFEST.in 2016-12-22 20:42:47.000000000 +0100 +++ new/flake8-pyi-18.3.1/MANIFEST.in 2018-12-08 22:22:09.000000000 +0100 @@ -1,2 +1,3 @@ include *.rst +include .flake8 recursive-include tests *.pyi *.py diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/flake8-pyi-18.3.1/PKG-INFO new/flake8-pyi-18.3.1/PKG-INFO --- old/flake8-pyi-18.3.1/PKG-INFO 2018-03-29 05:36:07.000000000 +0200 +++ new/flake8-pyi-18.3.1/PKG-INFO 2018-12-08 22:22:40.000000000 +0100 @@ -1,4 +1,4 @@ -Metadata-Version: 1.1 +Metadata-Version: 1.2 Name: flake8-pyi Version: 18.3.1 Summary: A plugin for flake8 to enable linting .pyi files. @@ -69,6 +69,10 @@ * Y011: All default values for typed function arguments must be "...". Type checkers ignore the default value, so the default value is not useful information in a stub file. + * Y012: Class body must not contain "pass". + * Y013: Non-empty class body must not contain "...". + * Y014: All default values for arguments must be "...". A stronger version + of Y011 that includes arguments without type annotations. The following warnings are disabled by default: @@ -109,6 +113,11 @@ Change Log ---------- + 18.10.0 + ~~~~~~~ + + * use --stdin-display-name as the filename when reading from stdin + 18.3.1 ~~~~~~ @@ -168,3 +177,4 @@ Classifier: Programming Language :: Python :: 3.6 Classifier: Topic :: Software Development :: Libraries :: Python Modules Classifier: Topic :: Software Development :: Quality Assurance +Requires-Python: >=3.6 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/flake8-pyi-18.3.1/README.rst new/flake8-pyi-18.3.1/README.rst --- old/flake8-pyi-18.3.1/README.rst 2018-03-29 05:35:25.000000000 +0200 +++ new/flake8-pyi-18.3.1/README.rst 2018-12-08 22:22:09.000000000 +0100 @@ -61,6 +61,10 @@ * Y011: All default values for typed function arguments must be "...". Type checkers ignore the default value, so the default value is not useful information in a stub file. +* Y012: Class body must not contain "pass". +* Y013: Non-empty class body must not contain "...". +* Y014: All default values for arguments must be "...". A stronger version + of Y011 that includes arguments without type annotations. The following warnings are disabled by default: @@ -101,6 +105,11 @@ Change Log ---------- +18.10.0 +~~~~~~~ + +* use --stdin-display-name as the filename when reading from stdin + 18.3.1 ~~~~~~ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/flake8-pyi-18.3.1/flake8_pyi.egg-info/PKG-INFO new/flake8-pyi-18.3.1/flake8_pyi.egg-info/PKG-INFO --- old/flake8-pyi-18.3.1/flake8_pyi.egg-info/PKG-INFO 2018-03-29 05:36:06.000000000 +0200 +++ new/flake8-pyi-18.3.1/flake8_pyi.egg-info/PKG-INFO 2018-12-08 22:22:39.000000000 +0100 @@ -1,4 +1,4 @@ -Metadata-Version: 1.1 +Metadata-Version: 1.2 Name: flake8-pyi Version: 18.3.1 Summary: A plugin for flake8 to enable linting .pyi files. @@ -69,6 +69,10 @@ * Y011: All default values for typed function arguments must be "...". Type checkers ignore the default value, so the default value is not useful information in a stub file. + * Y012: Class body must not contain "pass". + * Y013: Non-empty class body must not contain "...". + * Y014: All default values for arguments must be "...". A stronger version + of Y011 that includes arguments without type annotations. The following warnings are disabled by default: @@ -109,6 +113,11 @@ Change Log ---------- + 18.10.0 + ~~~~~~~ + + * use --stdin-display-name as the filename when reading from stdin + 18.3.1 ~~~~~~ @@ -168,3 +177,4 @@ Classifier: Programming Language :: Python :: 3.6 Classifier: Topic :: Software Development :: Libraries :: Python Modules Classifier: Topic :: Software Development :: Quality Assurance +Requires-Python: >=3.6 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/flake8-pyi-18.3.1/flake8_pyi.egg-info/SOURCES.txt new/flake8-pyi-18.3.1/flake8_pyi.egg-info/SOURCES.txt --- old/flake8-pyi-18.3.1/flake8_pyi.egg-info/SOURCES.txt 2018-03-29 05:36:06.000000000 +0200 +++ new/flake8-pyi-18.3.1/flake8_pyi.egg-info/SOURCES.txt 2018-12-08 22:22:40.000000000 +0100 @@ -1,3 +1,4 @@ +.flake8 MANIFEST.in README.rst pyi.py @@ -14,6 +15,7 @@ tests/comparisons.pyi tests/defaults.pyi tests/del.pyi +tests/emptyclasses.pyi tests/emptyfunctions.pyi tests/emptyinit.pyi tests/forward_refs.pyi diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/flake8-pyi-18.3.1/flake8_pyi.egg-info/requires.txt new/flake8-pyi-18.3.1/flake8_pyi.egg-info/requires.txt --- old/flake8-pyi-18.3.1/flake8_pyi.egg-info/requires.txt 2018-03-29 05:36:06.000000000 +0200 +++ new/flake8-pyi-18.3.1/flake8_pyi.egg-info/requires.txt 2018-12-08 22:22:39.000000000 +0100 @@ -1,2 +1,2 @@ -flake8 >= 3.2.1 +flake8>=3.2.1 attrs diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/flake8-pyi-18.3.1/pyi.py new/flake8-pyi-18.3.1/pyi.py --- old/flake8-pyi-18.3.1/pyi.py 2018-03-29 05:34:51.000000000 +0200 +++ new/flake8-pyi-18.3.1/pyi.py 2018-12-08 22:22:09.000000000 +0100 @@ -96,9 +96,9 @@ self.pushScope(ClassScope) # doctest does not process doctest within a doctest # classes within classes are processed. - if (self.withDoctest and - not self._in_doctest() and - not isinstance(self.scope, FunctionScope)): + if (self.withDoctest + and not self._in_doctest() + and not isinstance(self.scope, FunctionScope)): self.deferFunction(lambda: self.handleDoctests(node)) for stmt in node.body: self.handleNode(stmt, node) @@ -115,11 +115,16 @@ class PyiAwareFileChecker(checker.FileChecker): def run_check(self, plugin, **kwargs): - if self.filename.endswith('.pyi') and plugin['plugin'] == FlakesChecker: + if self.filename == '-': + filename = self.options.stdin_display_name + else: + filename = self.filename + + if filename.endswith('.pyi') and plugin['plugin'] == FlakesChecker: LOG.info( 'Replacing FlakesChecker with PyiAwareFlakesChecker while ' 'checking %r', - self.filename, + filename, ) plugin = dict(plugin) plugin['plugin'] = PyiAwareFlakesChecker @@ -247,6 +252,26 @@ else: self.error(node, Y007) + def visit_ClassDef(self, node: ast.ClassDef) -> None: + self.generic_visit(node) + + # empty class body should contain "..." not "pass" + if len(node.body) == 1: + statement = node.body[0] + if isinstance(statement, ast.Expr) and isinstance(statement.value, ast.Ellipsis): + return + elif isinstance(statement, ast.Pass): + self.error(statement, Y009) + return + + for i, statement in enumerate(node.body): + # "pass" should not used in class body + if isinstance(statement, ast.Pass): + self.error(statement, Y012) + # "..." should not be used in non-empty class body + elif isinstance(statement, ast.Expr) and isinstance(statement.value, ast.Ellipsis): + self.error(statement, Y013) + def visit_FunctionDef(self, node: ast.FunctionDef) -> None: self.generic_visit(node) @@ -274,10 +299,11 @@ for arg, default in chain(zip(args, node.defaults), zip(node.kwonlyargs, node.kw_defaults)): if default is None: continue # keyword-only arg without a default - if arg.annotation is None: - continue # we don't care if the argument is untyped if not isinstance(default, ast.Ellipsis): - self.error(default, Y011) + if arg.annotation is None: + self.error(default, Y014) + else: + self.error(default, Y011) def error(self, node: ast.AST, message: str) -> None: self.errors.append(Error( @@ -367,6 +393,9 @@ Y009 = 'Y009 Empty body should contain "...", not "pass"' Y010 = 'Y010 Function body must contain only "..."' Y011 = 'Y011 Default values for typed arguments must be "..."' +Y012 = 'Y012 Class body must not contain "pass"' +Y013 = 'Y013 Non-empty class body must not contain "..."' +Y014 = 'Y014 Default values for arguments must be "..."' Y090 = 'Y090 Use explicit attributes instead of assignments in __init__' DISABLED_BY_DEFAULT = [Y090] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/flake8-pyi-18.3.1/setup.cfg new/flake8-pyi-18.3.1/setup.cfg --- old/flake8-pyi-18.3.1/setup.cfg 2018-03-29 05:36:07.000000000 +0200 +++ new/flake8-pyi-18.3.1/setup.cfg 2018-12-08 22:22:40.000000000 +0100 @@ -4,5 +4,4 @@ [egg_info] tag_build = tag_date = 0 -tag_svn_revision = 0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/flake8-pyi-18.3.1/setup.py new/flake8-pyi-18.3.1/setup.py --- old/flake8-pyi-18.3.1/setup.py 2018-03-29 05:32:31.000000000 +0200 +++ new/flake8-pyi-18.3.1/setup.py 2018-12-08 22:22:09.000000000 +0100 @@ -35,6 +35,7 @@ license='MIT', py_modules=['pyi'], zip_safe=False, + python_requires=">=3.6", install_requires=['flake8 >= 3.2.1', 'attrs'], test_suite='tests.test_pyi', classifiers=[ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/flake8-pyi-18.3.1/tests/defaults.pyi new/flake8-pyi-18.3.1/tests/defaults.pyi --- old/flake8-pyi-18.3.1/tests/defaults.pyi 2018-03-29 05:32:31.000000000 +0200 +++ new/flake8-pyi-18.3.1/tests/defaults.pyi 2018-12-08 22:22:09.000000000 +0100 @@ -6,7 +6,7 @@ ... def f4(*, x: int = 3) -> None: # Y011 ... -def f5(x=3) -> None: # no error because it is unannotated +def f5(x=3) -> None: # Y014 ... def f6(*, x: int) -> None: # no error ... diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/flake8-pyi-18.3.1/tests/emptyclasses.pyi new/flake8-pyi-18.3.1/tests/emptyclasses.pyi --- old/flake8-pyi-18.3.1/tests/emptyclasses.pyi 1970-01-01 01:00:00.000000000 +0100 +++ new/flake8-pyi-18.3.1/tests/emptyclasses.pyi 2018-12-08 22:22:09.000000000 +0100 @@ -0,0 +1,21 @@ +class EmptyClass: + ... + +class PassingEmptyClass: + pass # Y009 + +class PassingNonEmptyClass: + x: int + pass # Y011 + +class PassingNonEmptyClass2: + pass # Y011 + x: int + +class EllipsisNonEmptyClass: + x: int + ... # Y012 + +class EllipsisNonEmptyClass2: + ... # Y012 + x: int diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/flake8-pyi-18.3.1/tests/test_pyi.py new/flake8-pyi-18.3.1/tests/test_pyi.py --- old/flake8-pyi-18.3.1/tests/test_pyi.py 2018-03-29 05:32:31.000000000 +0200 +++ new/flake8-pyi-18.3.1/tests/test_pyi.py 2018-12-08 22:22:09.000000000 +0100 @@ -28,24 +28,51 @@ stderr_text = proc.stderr.decode('utf8') return proc.returncode, stdout_text, stderr_text + def checkStdin(self, filename: str, pyi_aware: bool, + extra_options: Sequence[str] = ()) -> Tuple[int, str, str]: + file_path = Path(__file__).absolute().parent / filename + cmdline = ['flake8', '-j0', '--stdin-display-name=' + filename, *extra_options, '-'] + if not pyi_aware: + cmdline.insert(-1, '--no-pyi-aware-file-checker') + env = os.environ.copy() + env['PYTHONWARNINGS'] = 'ignore' + proc = subprocess.run( + cmdline, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + timeout=60, + env=env, + input=file_path.read_bytes(), + ) + stdout_text = proc.stdout.decode('utf8') + stderr_text = proc.stderr.decode('utf8') + return proc.returncode, stdout_text, stderr_text + def checkFileOutput(self, filename: str, *, pyi_aware: bool = True, stdout_lines: Sequence[str] = (), stderr_lines: Sequence[str] = (), extra_options: Sequence[str] = ()) -> None: - returncode, stdout, stderr = self.checkFile(filename, pyi_aware=pyi_aware, - extra_options=extra_options) - expected_returncode = 1 if stdout else 0 - - for (actual, expected_lines) in [(stderr, stderr_lines), (stdout, stdout_lines)]: - actual = '\n'.join( - line.split('/')[-1] for line in actual.split('\n') if line - ) - expected = '\n'.join( - '{filename}:{line}'.format(filename=filename, line=line) - for line in expected_lines - ) - self.assertMultiLineEqual(expected, actual) + def check_output(returncode: int, stdout: str, stderr: str): + expected_returncode = 1 if stdout else 0 - self.assertEqual(returncode, expected_returncode, stdout) + for (actual, expected_lines) in [(stderr, stderr_lines), (stdout, stdout_lines)]: + actual = '\n'.join( + line.split('/')[-1] for line in actual.split('\n') if line + ) + expected = '\n'.join( + '{filename}:{line}'.format(filename=filename, line=line) + for line in expected_lines + ) + self.assertMultiLineEqual(expected, actual) + + self.assertEqual(returncode, expected_returncode, stdout) + + with self.subTest(stdin=False): + check_output(*self.checkFile(filename, pyi_aware=pyi_aware, + extra_options=extra_options)) + + with self.subTest(stdin=True): + check_output(*self.checkStdin(filename, pyi_aware=pyi_aware, + extra_options=extra_options)) def test_vanilla_flake8_not_clean_forward_refs(self) -> None: stdout_lines = ( @@ -115,6 +142,16 @@ ) self.checkFileOutput('comparisons.pyi', stdout_lines=stdout_lines) + def test_class_def(self) -> None: + stdout_lines = ( + '5:5: Y009 Empty body should contain "...", not "pass"', + '9:5: Y012 Class body must not contain "pass"', + '12:5: Y012 Class body must not contain "pass"', + '17:5: Y013 Non-empty class body must not contain "..."', + '20:5: Y013 Non-empty class body must not contain "..."', + ) + self.checkFileOutput('emptyclasses.pyi', stdout_lines=stdout_lines) + def test_function_def(self) -> None: stdout_lines = ( '5:5: Y009 Empty body should contain "...", not "pass"', @@ -136,6 +173,7 @@ stdout_lines = ( '3:17: Y011 Default values for typed arguments must be "..."', '7:20: Y011 Default values for typed arguments must be "..."', + '9:10: Y014 Default values for arguments must be "..."', '13:20: Y011 Default values for typed arguments must be "..."', ) self.checkFileOutput('defaults.pyi', stdout_lines=stdout_lines)
