Hello community,

here is the log from the commit of package python-flake8-pyi for 
openSUSE:Factory checked in at 2020-05-28 09:07:00
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-flake8-pyi (Old)
 and      /work/SRC/openSUSE:Factory/.python-flake8-pyi.new.3606 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-flake8-pyi"

Thu May 28 09:07:00 2020 rev:5 rq:805997 version:20.5.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-flake8-pyi/python-flake8-pyi.changes      
2019-03-10 09:37:30.192145668 +0100
+++ 
/work/SRC/openSUSE:Factory/.python-flake8-pyi.new.3606/python-flake8-pyi.changes
    2020-05-28 09:07:07.111662901 +0200
@@ -1,0 +2,9 @@
+Fri May 15 21:22:02 UTC 2020 - Benjamin Greiner <[email protected]>
+
+- Update to v20.5.0
+  * support flake8 3.8.0
+  * introduce Y091 (function body must not contain "raise")
+  * introduce Y015 (attribute must not have a default value other than "...")
+  * introduce Y092 (top-level attribute must not have a default value) 
+
+-------------------------------------------------------------------

Old:
----
  flake8-pyi-19.3.0.tar.gz

New:
----
  flake8-pyi-20.5.0.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-flake8-pyi.spec ++++++
--- /var/tmp/diff_new_pack.Zvd0rq/_old  2020-05-28 09:07:07.959665444 +0200
+++ /var/tmp/diff_new_pack.Zvd0rq/_new  2020-05-28 09:07:07.963665456 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package python-flake8-pyi
 #
-# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2020 SUSE LLC
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -19,12 +19,12 @@
 %define skip_python2 1
 %{?!python_module:%define python_module() python-%{**} python3-%{**}}
 Name:           python-flake8-pyi
-Version:        19.3.0
+Version:        20.5.0
 Release:        0
 Summary:        A plugin for flake8 to enable linting .pyi files
 License:        MIT
 Group:          Development/Languages/Python
-Url:            https://github.com/ambv/flake8-pyi
+URL:            https://github.com/ambv/flake8-pyi
 Source:         
https://files.pythonhosted.org/packages/source/f/flake8-pyi/flake8-pyi-%{version}.tar.gz
 Source1:        
https://raw.githubusercontent.com/ambv/flake8-pyi/master/LICENSE
 BuildRequires:  %{python_module base >= 3.6.0}
@@ -50,7 +50,7 @@
 
 %description
 A plugin for Flake8 that provides specializations for type hinting stub
-files , especially interesting for linting typeshed.
+files. Especially interesting for linting typeshed.
 
 %prep
 %setup -q -n flake8-pyi-%{version}
@@ -62,14 +62,16 @@
 
 %install
 %python_install
-%fdupes %{buildroot}%{python3_sitelib}
+%python_expand %fdupes %{buildroot}%{$python_sitelib}
 
 %check
-PYTHONPATH=%{buildroot}%{python3_sitelib} py.test3 -v tests
+%pytest -v tests
 
 %files %{python_files}
 %license LICENSE
 %doc README.rst
-%{python3_sitelib}/*
+%{python_sitelib}/pyi.py*
+%{pycache_only %{python_sitelib}/__pycache__/pyi.*.py*}
+%{python_sitelib}/flake8_pyi-%{version}-*.egg-info
 
 %changelog

++++++ flake8-pyi-19.3.0.tar.gz -> flake8-pyi-20.5.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flake8-pyi-19.3.0/LICENSE 
new/flake8-pyi-20.5.0/LICENSE
--- old/flake8-pyi-19.3.0/LICENSE       1970-01-01 01:00:00.000000000 +0100
+++ new/flake8-pyi-20.5.0/LICENSE       2017-05-04 02:56:08.000000000 +0200
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2016 Łukasz Langa
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flake8-pyi-19.3.0/MANIFEST.in 
new/flake8-pyi-20.5.0/MANIFEST.in
--- old/flake8-pyi-19.3.0/MANIFEST.in   2018-12-08 16:46:26.000000000 +0100
+++ new/flake8-pyi-20.5.0/MANIFEST.in   2020-05-13 03:36:37.000000000 +0200
@@ -1,3 +1,4 @@
+include LICENSE
 include *.rst
 include .flake8
 recursive-include tests *.pyi *.py
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flake8-pyi-19.3.0/PKG-INFO 
new/flake8-pyi-20.5.0/PKG-INFO
--- old/flake8-pyi-19.3.0/PKG-INFO      2019-03-01 04:32:36.000000000 +0100
+++ new/flake8-pyi-20.5.0/PKG-INFO      2020-05-13 04:05:11.776741000 +0200
@@ -1,6 +1,6 @@
 Metadata-Version: 1.2
 Name: flake8-pyi
-Version: 19.3.0
+Version: 20.5.0
 Summary: A plugin for flake8 to enable linting .pyi files.
 Home-page: https://github.com/ambv/flake8-pyi
 Author: Łukasz Langa
@@ -73,6 +73,7 @@
         * 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.
+        * Y015: Attribute must not have a default value other than "...".
         
         The following warnings are disabled by default:
         
@@ -89,6 +90,8 @@
                  x: str
                  def __init__(self, x: str) -> None: ...
         
+        * Y091: Function body must not contain "raise".
+        * Y092: Top-level attribute must not have a default value.
         
         License
         -------
@@ -113,6 +116,14 @@
         Change Log
         ----------
         
+        20.5.0
+        ~~~~~~
+        
+        * support flake8 3.8.0
+        * introduce Y091 (function body must not contain "raise")
+        * introduce Y015 (attribute must not have a default value other than 
"...")
+        * introduce Y092 (top-level attribute must not have a default value)
+        
         19.3.0
         ~~~~~~
         
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flake8-pyi-19.3.0/README.rst 
new/flake8-pyi-20.5.0/README.rst
--- old/flake8-pyi-19.3.0/README.rst    2019-03-01 04:31:08.000000000 +0100
+++ new/flake8-pyi-20.5.0/README.rst    2020-05-13 03:39:53.000000000 +0200
@@ -65,6 +65,7 @@
 * 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.
+* Y015: Attribute must not have a default value other than "...".
 
 The following warnings are disabled by default:
 
@@ -81,6 +82,8 @@
          x: str
          def __init__(self, x: str) -> None: ...
 
+* Y091: Function body must not contain "raise".
+* Y092: Top-level attribute must not have a default value.
 
 License
 -------
@@ -105,6 +108,14 @@
 Change Log
 ----------
 
+20.5.0
+~~~~~~
+
+* support flake8 3.8.0
+* introduce Y091 (function body must not contain "raise")
+* introduce Y015 (attribute must not have a default value other than "...")
+* introduce Y092 (top-level attribute must not have a default value)
+
 19.3.0
 ~~~~~~
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flake8-pyi-19.3.0/flake8_pyi.egg-info/PKG-INFO 
new/flake8-pyi-20.5.0/flake8_pyi.egg-info/PKG-INFO
--- old/flake8-pyi-19.3.0/flake8_pyi.egg-info/PKG-INFO  2019-03-01 
04:32:36.000000000 +0100
+++ new/flake8-pyi-20.5.0/flake8_pyi.egg-info/PKG-INFO  2020-05-13 
04:05:11.000000000 +0200
@@ -1,6 +1,6 @@
 Metadata-Version: 1.2
 Name: flake8-pyi
-Version: 19.3.0
+Version: 20.5.0
 Summary: A plugin for flake8 to enable linting .pyi files.
 Home-page: https://github.com/ambv/flake8-pyi
 Author: Łukasz Langa
@@ -73,6 +73,7 @@
         * 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.
+        * Y015: Attribute must not have a default value other than "...".
         
         The following warnings are disabled by default:
         
@@ -89,6 +90,8 @@
                  x: str
                  def __init__(self, x: str) -> None: ...
         
+        * Y091: Function body must not contain "raise".
+        * Y092: Top-level attribute must not have a default value.
         
         License
         -------
@@ -113,6 +116,14 @@
         Change Log
         ----------
         
+        20.5.0
+        ~~~~~~
+        
+        * support flake8 3.8.0
+        * introduce Y091 (function body must not contain "raise")
+        * introduce Y015 (attribute must not have a default value other than 
"...")
+        * introduce Y092 (top-level attribute must not have a default value)
+        
         19.3.0
         ~~~~~~
         
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flake8-pyi-19.3.0/flake8_pyi.egg-info/SOURCES.txt 
new/flake8-pyi-20.5.0/flake8_pyi.egg-info/SOURCES.txt
--- old/flake8-pyi-19.3.0/flake8_pyi.egg-info/SOURCES.txt       2019-03-01 
04:32:36.000000000 +0100
+++ new/flake8-pyi-20.5.0/flake8_pyi.egg-info/SOURCES.txt       2020-05-13 
04:05:11.000000000 +0200
@@ -1,4 +1,5 @@
 .flake8
+LICENSE
 MANIFEST.in
 README.rst
 pyi.py
@@ -12,6 +13,7 @@
 flake8_pyi.egg-info/requires.txt
 flake8_pyi.egg-info/top_level.txt
 tests/__init__.py
+tests/attribute_annotations.pyi
 tests/comparisons.pyi
 tests/defaults.pyi
 tests/del.pyi
@@ -20,6 +22,7 @@
 tests/emptyinit.pyi
 tests/forward_refs.pyi
 tests/forward_refs_annassign.pyi
+tests/raise.pyi
 tests/sysplatform.pyi
 tests/sysversioninfo.pyi
 tests/test_pyi.py
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flake8-pyi-19.3.0/pyi.py new/flake8-pyi-20.5.0/pyi.py
--- old/flake8-pyi-19.3.0/pyi.py        2019-03-01 04:31:58.000000000 +0100
+++ new/flake8-pyi-20.5.0/pyi.py        2020-05-13 04:04:10.000000000 +0200
@@ -1,6 +1,7 @@
 #!/usr/bin/env python3
 import logging
 
+import argparse
 import ast
 import attr
 from flake8 import checker
@@ -12,7 +13,7 @@
 from pyflakes.checker import ModuleScope, ClassScope, FunctionScope
 from typing import Any, Iterable, NamedTuple, Optional, Type
 
-__version__ = "19.3.0"
+__version__ = "20.5.0"
 
 LOG = logging.getLogger("flake8.pyi")
 
@@ -135,12 +136,12 @@
 class PyiVisitor(ast.NodeVisitor):
     filename = attr.ib(default=Path("(none)"))
     errors = attr.ib(default=attr.Factory(list))
+    _in_class = attr.ib(default=0)
 
     def visit_Assign(self, node: ast.Assign) -> None:
-        """Attempt to find assignments to type helpers (typevars and aliases), 
which should be
-        private.
-        """
         self.generic_visit(node)
+        # Attempt to find assignments to type helpers (typevars and aliases), 
which should be
+        # private.
         if (
             isinstance(node.value, ast.Call)
             and isinstance(node.value.func, ast.Name)
@@ -151,6 +152,16 @@
                     # avoid catching AnyStr in typing (the only library 
TypeVar so far)
                     if not self.filename.name == "typing.pyi":
                         self.error(target, Y001)
+        if len(node.targets) == 1 and isinstance(node.targets[0], ast.Name):
+            if isinstance(node.value, (ast.Num, ast.Str)):
+                self.error(node.value, Y015)
+
+    def visit_AnnAssign(self, node: ast.AnnAssign) -> None:
+        if isinstance(node.target, ast.Name):
+            if node.value and not isinstance(node.value, ast.Ellipsis):
+                self.error(node.value, Y015)
+            elif node.value and not self._in_class:
+                self.error(node.value, Y092)
 
     def visit_If(self, node: ast.If) -> None:
         self.generic_visit(node)
@@ -263,7 +274,9 @@
             self.error(node, Y007)
 
     def visit_ClassDef(self, node: ast.ClassDef) -> None:
+        self._in_class += 1
         self.generic_visit(node)
+        self._in_class -= 1
 
         # empty class body should contain "..." not "pass"
         if len(node.body) == 1:
@@ -299,8 +312,9 @@
                     statement.value, ast.Ellipsis
                 ):
                     continue
-            # allow "raise", a number of stubs have this
+            # special-case raise for backwards compatibility
             if isinstance(statement, ast.Raise):
+                self.error(statement, Y091)
                 continue
             # allow assignments in constructor for now
             # (though these should probably be changed)
@@ -352,12 +366,15 @@
     @classmethod
     def add_options(cls, parser):
         """This is brittle, there's multiple levels of caching of defaults."""
-        for option in parser.options:
-            if option.long_option_name == "--filename":
-                option.default = "*.py,*.pyi"
-                option.option_kwargs["default"] = option.default
-                option.to_optparse().default = option.default
-                parser.parser.defaults[option.dest] = option.default
+        if isinstance(parser.parser, argparse.ArgumentParser):
+            parser.parser.set_defaults(filename="*.py,*.pyi")
+        else:
+            for option in parser.options:
+                if option.long_option_name == "--filename":
+                    option.default = "*.py,*.pyi"
+                    option.option_kwargs["default"] = option.default
+                    option.to_optparse().default = option.default
+                    parser.parser.defaults[option.dest] = option.default
 
         try:
             parser.add_option(
@@ -417,6 +434,9 @@
 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 "..."'
+Y015 = 'Y015 Attribute must not have a default value other than "..."'
 Y090 = "Y090 Use explicit attributes instead of assignments in __init__"
+Y091 = 'Y091 Function body must not contain "raise"'
+Y092 = "Y092 Top-level attribute must not have a default value"
 
-DISABLED_BY_DEFAULT = [Y090]
+DISABLED_BY_DEFAULT = [Y090, Y091, Y092]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flake8-pyi-19.3.0/tests/attribute_annotations.pyi 
new/flake8-pyi-20.5.0/tests/attribute_annotations.pyi
--- old/flake8-pyi-19.3.0/tests/attribute_annotations.pyi       1970-01-01 
01:00:00.000000000 +0100
+++ new/flake8-pyi-20.5.0/tests/attribute_annotations.pyi       2020-05-13 
03:36:37.000000000 +0200
@@ -0,0 +1,22 @@
+# ok
+field1: int
+field2: int = ...  # Y092
+field3 = ...  # type: int
+
+# not ok
+field4: int = 0
+field5 = 0  # type: int
+field6 = 0
+field7 = ""
+
+class Foo:
+    # ok
+    field1: int
+    field2: int = ...
+    field3 = ...  # type: int
+
+    # not ok
+    field4: int = 0
+    field5 = 0  # type: int
+    field6 = 0
+    field7 = ""
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flake8-pyi-19.3.0/tests/forward_refs_annassign.pyi 
new/flake8-pyi-20.5.0/tests/forward_refs_annassign.pyi
--- old/flake8-pyi-19.3.0/tests/forward_refs_annassign.pyi      2018-03-29 
04:48:39.000000000 +0200
+++ new/flake8-pyi-20.5.0/tests/forward_refs_annassign.pyi      2020-05-13 
03:36:37.000000000 +0200
@@ -4,7 +4,7 @@
 MaybeCStr = Optional[CStr]
 CStr = Union[C, str]
 __version__: str
-__author__: str = ...
+__author__: str
 
 
 def make_default_c() -> C:
@@ -19,7 +19,7 @@
 
 
 class C:
-    other: C = None
+    other: C = ...
 
     def __init__(self) -> None:
         ...
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flake8-pyi-19.3.0/tests/raise.pyi 
new/flake8-pyi-20.5.0/tests/raise.pyi
--- old/flake8-pyi-19.3.0/tests/raise.pyi       1970-01-01 01:00:00.000000000 
+0100
+++ new/flake8-pyi-20.5.0/tests/raise.pyi       2020-05-13 03:36:37.000000000 
+0200
@@ -0,0 +1,6 @@
+class Foo:
+    def __init__(self) -> None:
+        raise ValueError()  # Y091
+
+    def foo(self) -> None:
+        raise ValueError()  # Y091
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flake8-pyi-19.3.0/tests/test_pyi.py 
new/flake8-pyi-20.5.0/tests/test_pyi.py
--- old/flake8-pyi-19.3.0/tests/test_pyi.py     2019-02-24 02:07:16.000000000 
+0100
+++ new/flake8-pyi-20.5.0/tests/test_pyi.py     2020-05-13 03:36:37.000000000 
+0200
@@ -191,6 +191,16 @@
             "emptyinit.pyi", stdout_lines=stdout_lines, 
extra_options=("--select=Y090",)
         )
 
+    def test_raise_in_function_body(self) -> None:
+        self.checkFileOutput("raise.pyi", stdout_lines=())
+        stdout_lines = (
+            '3:9: Y091 Function body must not contain "raise"',
+            '6:9: Y091 Function body must not contain "raise"',
+        )
+        self.checkFileOutput(
+            "raise.pyi", stdout_lines=stdout_lines, 
extra_options=("--select=Y091",)
+        )
+
     def test_defaults(self) -> None:
         stdout_lines = (
             '3:17: Y011 Default values for typed arguments must be "..."',
@@ -200,6 +210,27 @@
         )
         self.checkFileOutput("defaults.pyi", stdout_lines=stdout_lines)
 
+    def test_attribute_values(self) -> None:
+        stdout_lines = (
+            '7:15: Y015 Attribute must not have a default value other than 
"..."',
+            '8:10: Y015 Attribute must not have a default value other than 
"..."',
+            '9:10: Y015 Attribute must not have a default value other than 
"..."',
+            '10:10: Y015 Attribute must not have a default value other than 
"..."',
+            '19:19: Y015 Attribute must not have a default value other than 
"..."',
+            '20:14: Y015 Attribute must not have a default value other than 
"..."',
+            '21:14: Y015 Attribute must not have a default value other than 
"..."',
+            '22:14: Y015 Attribute must not have a default value other than 
"..."',
+        )
+        self.checkFileOutput("attribute_annotations.pyi", 
stdout_lines=stdout_lines)
+
+    def test_attribute_values_strict(self) -> None:
+        stdout_lines = ("3:15: Y092 Top-level attribute must not have a 
default value",)
+        self.checkFileOutput(
+            "attribute_annotations.pyi",
+            stdout_lines=stdout_lines,
+            extra_options=("--select=Y092",),
+        )
+
 
 if __name__ == "__main__":
     unittest.main()


Reply via email to