Hello community,
here is the log from the commit of package python-flake8-builtins for
openSUSE:Factory checked in at 2020-04-16 23:05:20
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-flake8-builtins (Old)
and /work/SRC/openSUSE:Factory/.python-flake8-builtins.new.2738 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-flake8-builtins"
Thu Apr 16 23:05:20 2020 rev:3 rq:794562 version:1.5.2
Changes:
--------
---
/work/SRC/openSUSE:Factory/python-flake8-builtins/python-flake8-builtins.changes
2019-08-27 10:20:06.767944656 +0200
+++
/work/SRC/openSUSE:Factory/.python-flake8-builtins.new.2738/python-flake8-builtins.changes
2020-04-16 23:05:24.859790202 +0200
@@ -1,0 +2,10 @@
+Thu Apr 16 10:50:24 UTC 2020 - Tomáš Chvátal <[email protected]>
+
+- Update to 1.5.2:
+ * Add python3.8 support. [sobolevn]
+ * Add AnnAssign support. [soboelvn]
+ * Add NamedExpr or := support. [sobolevn]
+ * Adds kwonly and posonly args support. [sobolevn]
+ * Add DictComp, SetComp, and GeneratorExpr support. [sobolevn]
+
+-------------------------------------------------------------------
Old:
----
flake8-builtins-1.4.1.tar.gz
New:
----
flake8-builtins-1.5.2.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-flake8-builtins.spec ++++++
--- /var/tmp/diff_new_pack.AFy7rD/_old 2020-04-16 23:05:26.455791623 +0200
+++ /var/tmp/diff_new_pack.AFy7rD/_new 2020-04-16 23:05:26.459791626 +0200
@@ -1,7 +1,7 @@
#
# spec file for package python-flake8-builtins
#
-# 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
@@ -17,30 +17,25 @@
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
+%define skip_python2 1
Name: python-flake8-builtins
-Version: 1.4.1
+Version: 1.5.2
Release: 0
Summary: Flake8 Builtins plugin
License: GPL-2.0-only
-Group: Development/Languages/Python
-Url: https://github.com/gforcada/flake8-builtins
+URL: https://github.com/gforcada/flake8-builtins
Source:
https://files.pythonhosted.org/packages/source/f/flake8-builtins/flake8-builtins-%{version}.tar.gz
BuildRequires: %{python_module setuptools}
+BuildRequires: fdupes
BuildRequires: python-rpm-macros
+Requires: python-flake8
+BuildArch: noarch
# SECTION test requirements
BuildRequires: %{python_module flake8}
-BuildRequires: %{python_module mock}
+BuildRequires: %{python_module hypothesis}
+BuildRequires: %{python_module hypothesmith}
BuildRequires: %{python_module pytest}
# /SECTION
-BuildRequires: fdupes
-Requires: python-flake8
-Suggests: python-coverage
-Suggests: python-coveralls
-Suggests: python-mock
-Suggests: python-pytest
-Suggests: python-pytest-cov
-BuildArch: noarch
-
%python_subpackages
%description
@@ -57,10 +52,11 @@
%python_expand %fdupes %{buildroot}%{$python_sitelib}
%check
-%pytest run_tests.py
+# test_builtin_works_on_many_examples - will crash in obs as it is speed
related
+%pytest run_tests.py -k 'not test_builtin_works_on_many_examples'
%files %{python_files}
-%license LICENSE LICENSE.rst
+%license LICENSE
%doc CHANGES.rst README.rst
%{python_sitelib}/*
++++++ flake8-builtins-1.4.1.tar.gz -> flake8-builtins-1.5.2.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/flake8-builtins-1.4.1/CHANGES.rst
new/flake8-builtins-1.5.2/CHANGES.rst
--- old/flake8-builtins-1.4.1/CHANGES.rst 2018-05-11 11:30:04.000000000
+0200
+++ new/flake8-builtins-1.5.2/CHANGES.rst 2020-03-16 13:16:48.000000000
+0100
@@ -3,6 +3,37 @@
Changelog
=========
+1.5.2 (2020-03-16)
+------------------
+
+- Add `DictComp`, `SetComp`, and `GeneratorExpr` support.
+ [sobolevn]
+
+1.5.1 (2020-03-16)
+------------------
+
+- Adds kwonly and posonly args support.
+ [sobolevn]
+
+1.5.0 (2020-03-14)
+------------------
+
+- Add ``python3.8`` support.
+ [sobolevn]
+
+- Add ``AnnAssign`` support.
+ [soboelvn]
+
+- Add ``NamedExpr`` or ``:=`` support.
+ [sobolevn]
+
+
+1.4.2 (2019-12-18)
+------------------
+
+- Fix tuple parsing.
+ [memery-imb]
+
1.4.1 (2018-05-11)
------------------
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/flake8-builtins-1.4.1/LICENSE.rst
new/flake8-builtins-1.5.2/LICENSE.rst
--- old/flake8-builtins-1.4.1/LICENSE.rst 2018-05-11 11:30:04.000000000
+0200
+++ new/flake8-builtins-1.5.2/LICENSE.rst 1970-01-01 01:00:00.000000000
+0100
@@ -1,17 +0,0 @@
-.. -*- coding: utf-8 -*-
-
-flake8-builtins Copyright 2016, Gil Forcada
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License version 2
-as published by the Free Software Foundation.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place, Suite 330, Boston,
-MA 02111-1307 USA.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/flake8-builtins-1.4.1/MANIFEST.in
new/flake8-builtins-1.5.2/MANIFEST.in
--- old/flake8-builtins-1.4.1/MANIFEST.in 2018-05-11 11:30:04.000000000
+0200
+++ new/flake8-builtins-1.5.2/MANIFEST.in 1970-01-01 01:00:00.000000000
+0100
@@ -1,11 +0,0 @@
-include MANIFEST.in
-include LICENSE
-include setup.cfg
-include *.rst
-include *.py
-include *requirements.txt
-
-exclude .installed.cfg
-exclude .coveragerc
-exclude *.pyc
-
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/flake8-builtins-1.4.1/PKG-INFO
new/flake8-builtins-1.5.2/PKG-INFO
--- old/flake8-builtins-1.4.1/PKG-INFO 2018-05-11 11:30:04.000000000 +0200
+++ new/flake8-builtins-1.5.2/PKG-INFO 2020-03-16 13:16:48.000000000 +0100
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: flake8-builtins
-Version: 1.4.1
+Version: 1.5.2
Summary: Check for python builtins being used as variables or parameters.
Home-page: https://github.com/gforcada/flake8-builtins
Author: Gil Forcada
@@ -91,6 +91,37 @@
Changelog
=========
+ 1.5.2 (2020-03-16)
+ ------------------
+
+ - Add `DictComp`, `SetComp`, and `GeneratorExpr` support.
+ [sobolevn]
+
+ 1.5.1 (2020-03-16)
+ ------------------
+
+ - Adds kwonly and posonly args support.
+ [sobolevn]
+
+ 1.5.0 (2020-03-14)
+ ------------------
+
+ - Add ``python3.8`` support.
+ [sobolevn]
+
+ - Add ``AnnAssign`` support.
+ [soboelvn]
+
+ - Add ``NamedExpr`` or ``:=`` support.
+ [sobolevn]
+
+
+ 1.4.2 (2019-12-18)
+ ------------------
+
+ - Fix tuple parsing.
+ [memery-imb]
+
1.4.1 (2018-05-11)
------------------
@@ -268,8 +299,9 @@
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
-Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
+Classifier: Programming Language :: Python :: 3.7
+Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Software Development
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/flake8-builtins-1.4.1/dev-requirements.txt
new/flake8-builtins-1.5.2/dev-requirements.txt
--- old/flake8-builtins-1.4.1/dev-requirements.txt 2018-05-11
11:30:04.000000000 +0200
+++ new/flake8-builtins-1.5.2/dev-requirements.txt 1970-01-01
01:00:00.000000000 +0100
@@ -1,40 +0,0 @@
--r requirements.txt
--e .[test]
-asn1crypto==0.24.0
-attrs==17.4.0
-certifi==2018.1.18
-cffi==1.11.5
-chardet==3.0.4
-coverage==4.5.1
-coveralls==1.3.0
-cryptography==2.1.4
-docopt==0.6.2
-flake8-blind-except==0.1.1
-flake8-coding==1.3.0
-flake8-commas==1.0.0
-flake8-debugger==3.1.0
-flake8-deprecated==1.3
-flake8-isort==2.5
-flake8-pep3101==1.2
-flake8-polyfill==1.0.2
-flake8-print==3.1.0
-flake8-quotes==0.14.0
-flake8-string-format==0.2.3
-flake8-todo==0.7
-funcsigs==1.0.2
-futures==3.2.0; python_version < '3.0'
-idna==2.6
-ipaddress==1.0.19
-isort==4.3.4
-mock==2.0.0
-pbr==3.1.1
-pluggy==0.6.0
-py==1.5.2
-pycparser==2.18
-pyOpenSSL==17.5.0
-pytest==3.4.2
-pytest-cov==2.5.1
-requests==2.18.4
-six==1.11.0
-testfixtures==5.4.0
-urllib3==1.22
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/flake8-builtins-1.4.1/flake8_builtins.egg-info/PKG-INFO
new/flake8-builtins-1.5.2/flake8_builtins.egg-info/PKG-INFO
--- old/flake8-builtins-1.4.1/flake8_builtins.egg-info/PKG-INFO 2018-05-11
11:30:04.000000000 +0200
+++ new/flake8-builtins-1.5.2/flake8_builtins.egg-info/PKG-INFO 2020-03-16
13:16:48.000000000 +0100
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: flake8-builtins
-Version: 1.4.1
+Version: 1.5.2
Summary: Check for python builtins being used as variables or parameters.
Home-page: https://github.com/gforcada/flake8-builtins
Author: Gil Forcada
@@ -91,6 +91,37 @@
Changelog
=========
+ 1.5.2 (2020-03-16)
+ ------------------
+
+ - Add `DictComp`, `SetComp`, and `GeneratorExpr` support.
+ [sobolevn]
+
+ 1.5.1 (2020-03-16)
+ ------------------
+
+ - Adds kwonly and posonly args support.
+ [sobolevn]
+
+ 1.5.0 (2020-03-14)
+ ------------------
+
+ - Add ``python3.8`` support.
+ [sobolevn]
+
+ - Add ``AnnAssign`` support.
+ [soboelvn]
+
+ - Add ``NamedExpr`` or ``:=`` support.
+ [sobolevn]
+
+
+ 1.4.2 (2019-12-18)
+ ------------------
+
+ - Fix tuple parsing.
+ [memery-imb]
+
1.4.1 (2018-05-11)
------------------
@@ -268,8 +299,9 @@
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
-Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
+Classifier: Programming Language :: Python :: 3.7
+Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Software Development
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/flake8-builtins-1.4.1/flake8_builtins.egg-info/SOURCES.txt
new/flake8-builtins-1.5.2/flake8_builtins.egg-info/SOURCES.txt
--- old/flake8-builtins-1.4.1/flake8_builtins.egg-info/SOURCES.txt
2018-05-11 11:30:04.000000000 +0200
+++ new/flake8-builtins-1.5.2/flake8_builtins.egg-info/SOURCES.txt
2020-03-16 13:16:48.000000000 +0100
@@ -1,9 +1,6 @@
CHANGES.rst
LICENSE
-LICENSE.rst
-MANIFEST.in
README.rst
-dev-requirements.txt
flake8_builtins.py
requirements.txt
run_tests.py
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/flake8-builtins-1.4.1/flake8_builtins.py
new/flake8-builtins-1.5.2/flake8_builtins.py
--- old/flake8-builtins-1.4.1/flake8_builtins.py 2018-05-11
11:30:04.000000000 +0200
+++ new/flake8-builtins-1.5.2/flake8_builtins.py 2020-03-16
13:16:48.000000000 +0100
@@ -10,12 +10,12 @@
from flake8 import utils as stdin_utils
-WHITE_LIST = [
+WHITE_LIST = {
'__name__',
'__doc__',
'credits',
'_',
-]
+}
if sys.version_info >= (3, 0):
@@ -35,10 +35,20 @@
]
PY3 = False
+if sys.version_info >= (3, 6):
+ AnnAssign = ast.AnnAssign
+else: # There was no `AnnAssign` before python3.6
+ AnnAssign = type('AnnAssign', (ast.AST, ), {})
+
+if sys.version_info >= (3, 8):
+ NamedExpr = ast.NamedExpr
+else: # There was no walrus operator before python3.8
+ NamedExpr = type('NamedExpr', (ast.AST, ), {})
+
class BuiltinsChecker(object):
name = 'flake8_builtins'
- version = '1.4.1'
+ version = '1.5.2'
assign_msg = 'A001 "{0}" is a python builtin and is being shadowed, ' \
'consider renaming the variable'
argument_msg = 'A002 "{0}" is used as an argument and thus shadows a ' \
@@ -76,9 +86,16 @@
with_nodes.append(ast.AsyncWith)
with_nodes = tuple(with_nodes)
+ comprehension_nodes = (
+ ast.ListComp,
+ ast.SetComp,
+ ast.DictComp,
+ ast.GeneratorExp,
+ )
+
+ value = None
for statement in ast.walk(tree):
- value = None
- if isinstance(statement, ast.Assign):
+ if isinstance(statement, (ast.Assign, AnnAssign, NamedExpr)):
value = self.check_assignment(statement)
elif isinstance(statement, function_nodes):
@@ -93,8 +110,8 @@
elif isinstance(statement, ast.excepthandler):
value = self.check_exception(statement)
- elif isinstance(statement, ast.ListComp):
- value = self.check_list_comprehension(statement)
+ elif isinstance(statement, comprehension_nodes):
+ value = self.check_comprehension(statement)
elif isinstance(statement, (ast.Import, ast.ImportFrom)):
value = self.check_import(statement)
@@ -111,7 +128,11 @@
if type(statement.__flake8_builtins_parent) is ast.ClassDef:
msg = self.class_attribute_msg
- stack = list(statement.targets)
+ if isinstance(statement, ast.Assign):
+ stack = list(statement.targets)
+ else: # This is `ast.AnnAssign` or `ast.NamedExpr`:
+ stack = [statement.target]
+
while stack:
item = stack.pop()
if isinstance(item, (ast.Tuple, ast.List)):
@@ -119,14 +140,15 @@
elif isinstance(item, ast.Name) and \
item.id in BUILTINS:
yield self.error(item, message=msg, variable=item.id)
- elif PY3 and \
- isinstance(item, ast.Starred) and \
- item.value.id in BUILTINS:
- yield self.error(
- statement,
- message=msg,
- variable=item.value.id,
- )
+ elif PY3 and isinstance(item, ast.Starred):
+ if hasattr(item.value, 'id') and item.value.id in BUILTINS:
+ yield self.error(
+ statement,
+ message=msg,
+ variable=item.value.id,
+ )
+ elif hasattr(item.value, 'elts'):
+ stack.extend(list(item.value.elts))
def check_function_definition(self, statement):
if statement.name in BUILTINS:
@@ -137,7 +159,12 @@
yield self.error(statement, message=msg, variable=statement.name)
if PY3:
- for arg in statement.args.args:
+ all_arguments = []
+ all_arguments.extend(statement.args.args)
+ all_arguments.extend(getattr(statement.args, 'kwonlyargs', []))
+ all_arguments.extend(getattr(statement.args, 'posonlyargs', []))
+
+ for arg in all_arguments:
if isinstance(arg, ast.arg) and \
arg.arg in BUILTINS:
yield self.error(
@@ -160,10 +187,14 @@
elif isinstance(item, ast.Name) and \
item.id in BUILTINS:
yield self.error(statement, variable=item.id)
- elif PY3 and \
- isinstance(item, ast.Starred) and \
- item.value.id in BUILTINS:
- yield self.error(statement, variable=item.value.id)
+ elif PY3 and isinstance(item, ast.Starred):
+ if hasattr(item.value, 'id') and item.value.id in BUILTINS:
+ yield self.error(
+ statement,
+ variable=item.value.id,
+ )
+ elif hasattr(item.value, 'elts'):
+ stack.extend(list(item.value.elts))
def check_with(self, statement):
if not PY3:
@@ -205,7 +236,7 @@
if value in BUILTINS:
yield self.error(statement, variable=value)
- def check_list_comprehension(self, statement):
+ def check_comprehension(self, statement):
for generator in statement.generators:
if isinstance(generator.target, ast.Name) \
and generator.target.id in BUILTINS:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/flake8-builtins-1.4.1/requirements.txt
new/flake8-builtins-1.5.2/requirements.txt
--- old/flake8-builtins-1.4.1/requirements.txt 2018-05-11 11:30:04.000000000
+0200
+++ new/flake8-builtins-1.5.2/requirements.txt 2020-03-16 13:16:48.000000000
+0100
@@ -1,7 +1,56 @@
-.
-configparser==3.5.0
-enum34==1.1.6
-flake8==3.5.0
-mccabe==0.6.1
-pycodestyle==2.3.1
-pyflakes==1.6.0
+#
+# This file is autogenerated by pip-compile
+# To update, run:
+#
+# pip-compile
+#
+attrs==19.3.0 # via hypothesis, pytest
+certifi==2019.11.28 # via requests
+chardet==3.0.4 # via requests
+coverage==5.0.3 # via coveralls, pytest-cov
+coveralls==1.11.1 # via -r requirements.in
+docopt==0.6.2 # via coveralls
+entrypoints==0.3 # via flake8
+flake8-blind-except==0.1.1 # via -r requirements.in
+flake8-coding==1.3.2 # via -r requirements.in
+flake8-commas==2.0.0 # via -r requirements.in
+flake8-debugger==3.2.1 # via -r requirements.in
+flake8-deprecated==1.3 # via -r requirements.in
+flake8-isort==2.8.0 # via -r requirements.in
+flake8-pep3101==1.3.0 # via -r requirements.in
+flake8-polyfill==1.0.2 # via -r requirements.in
+flake8-print==3.1.4 # via -r requirements.in
+flake8-quotes==2.1.1 # via -r requirements.in
+flake8-string-format==0.3.0 # via -r requirements.in
+flake8-todo==0.7 # via -r requirements.in
+flake8==3.7.9 # via flake8-coding, flake8-commas, flake8-debugger,
flake8-deprecated, flake8-isort, flake8-pep3101, flake8-polyfill, flake8-print,
flake8-quotes, flake8-string-format
+hypothesis==5.6.0 ; python_version >= "3.6" # via -r requirements.in,
hypothesmith
+hypothesmith==0.0.5 ; python_version >= "3.6" # via -r requirements.in
+idna==2.9 # via requests
+importlib-metadata==1.5.0 # via pluggy, pytest
+isort[pyproject]==4.3.21 # via flake8-isort
+lark-parser==0.8.2 # via hypothesmith
+mccabe==0.6.1 # via flake8
+more-itertools==5.0.0 # via -r requirements.in, pytest
+packaging==20.3 # via pytest
+pluggy==0.13.1 # via pytest
+py==1.8.1 # via pytest
+pycodestyle==2.5.0 # via flake8, flake8-debugger, flake8-print,
flake8-todo
+pyflakes==2.1.1 # via flake8
+pyparsing==2.4.6 # via packaging
+pytest-cov==2.8.1 # via -r requirements.in
+pytest==5.4.1 ; python_version >= "3.0" # via -r requirements.in, pytest-cov
+requests==2.23.0 # via coveralls
+six==1.14.0 # via flake8-print, more-itertools, packaging
+sortedcontainers==2.1.0 # via hypothesis
+testfixtures==6.14.0 # via flake8-isort
+toml==0.10.0 # via isort
+urllib3==1.25.8 # via requests
+wcwidth==0.1.8 # via pytest
+zipp==3.1.0 ; python_version >= "3.0" # via -r requirements.in,
importlib-metadata
+
+# The following packages are considered to be unsafe in a requirements file:
+# setuptools
+
+# added manually
+mock==3.0.5 ; python_version < '3.0'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/flake8-builtins-1.4.1/run_tests.py
new/flake8-builtins-1.5.2/run_tests.py
--- old/flake8-builtins-1.4.1/run_tests.py 2018-05-11 11:30:04.000000000
+0200
+++ new/flake8-builtins-1.5.2/run_tests.py 2020-03-16 13:16:48.000000000
+0100
@@ -2,12 +2,23 @@
from flake8_builtins import BuiltinsChecker
import ast
-import mock
import pytest
import sys
import unittest
+try:
+ from unittest import mock
+except ImportError:
+ import mock
+
+
+if sys.version_info >= (3, 6):
+ from hypothesis import given
+ from hypothesis import reject
+ import hypothesmith
+
+
class TestBuiltins(unittest.TestCase):
def assert_codes(self, ret, codes):
self.assertEqual(len(ret), len(codes))
@@ -20,6 +31,26 @@
ret = [c for c in checker.run()]
self.assert_codes(ret, ['A001'])
+ @pytest.mark.skipif(
+ sys.version_info < (3, 6),
+ reason='AnnAssign appeared in 3.6',
+ )
+ def test_ann_assign(self):
+ tree = ast.parse('list: int = 1')
+ checker = BuiltinsChecker(tree, '/home/script.py')
+ ret = [c for c in checker.run()]
+ self.assert_codes(ret, ['A001'])
+
+ @pytest.mark.skipif(
+ sys.version_info < (3, 8),
+ reason='NamedExpr appeared in 3.8',
+ )
+ def test_walrus_operator(self):
+ tree = ast.parse('(dict := 1)')
+ checker = BuiltinsChecker(tree, '/home/script.py')
+ ret = [c for c in checker.run()]
+ self.assert_codes(ret, ['A001'])
+
def test_nested(self):
tree = ast.parse(
'def bla():\n'
@@ -97,6 +128,26 @@
ret = [c for c in checker.run()]
self.assert_codes(ret, ['A002'])
+ @pytest.mark.skipif(
+ sys.version_info < (3, 6),
+ reason='This syntax is only valid in Python 3.6+',
+ )
+ def test_kwonly_argument_message(self):
+ tree = ast.parse('def bla(*, list):\n a = 4')
+ checker = BuiltinsChecker(tree, '/home/script.py')
+ ret = [c for c in checker.run()]
+ self.assert_codes(ret, ['A002'])
+
+ @pytest.mark.skipif(
+ sys.version_info < (3, 8),
+ reason='This syntax is only valid in Python 3.8+',
+ )
+ def test_posonly_argument_message(self):
+ tree = ast.parse('def bla(list, /):\n a = 4')
+ checker = BuiltinsChecker(tree, '/home/script.py')
+ ret = [c for c in checker.run()]
+ self.assert_codes(ret, ['A002'])
+
def test_no_error(self):
tree = ast.parse('def bla(first):\n b = 4')
checker = BuiltinsChecker(tree, '/home/script.py')
@@ -298,9 +349,25 @@
self.assertEqual(len(ret), 0)
def test_list_comprehension(self):
- tree = ast.parse(
- 'a = [int for int in range(3,9)]\n',
- )
+ tree = ast.parse('a = [int for int in range(3,9)]')
+ checker = BuiltinsChecker(tree, '/home/script.py')
+ ret = [c for c in checker.run()]
+ self.assertEqual(len(ret), 1)
+
+ def test_set_comprehension(self):
+ tree = ast.parse('a = {int for int in range(3,9)}')
+ checker = BuiltinsChecker(tree, '/home/script.py')
+ ret = [c for c in checker.run()]
+ self.assertEqual(len(ret), 1)
+
+ def test_dict_comprehension(self):
+ tree = ast.parse('a = {int:"a" for int in range(3,9)}')
+ checker = BuiltinsChecker(tree, '/home/script.py')
+ ret = [c for c in checker.run()]
+ self.assertEqual(len(ret), 1)
+
+ def test_gen_comprehension(self):
+ tree = ast.parse('a = (int for int in range(3,9))')
checker = BuiltinsChecker(tree, '/home/script.py')
ret = [c for c in checker.run()]
self.assertEqual(len(ret), 1)
@@ -313,6 +380,14 @@
ret = [c for c in checker.run()]
self.assertEqual(len(ret), 2)
+ def test_list_comprehension_nested(self):
+ tree = ast.parse(
+ 'a = [(int, str) for int in some() for str in other()]\n',
+ )
+ checker = BuiltinsChecker(tree, '/home/script.py')
+ ret = [c for c in checker.run()]
+ self.assertEqual(len(ret), 2)
+
def test_list_comprehension_multiple_as_list(self):
tree = ast.parse(
'a = [(int, a) for [int, a] in enumerate(range(3,9))]\n',
@@ -482,3 +557,26 @@
len(ret),
1,
)
+
+ @pytest.mark.skipif(
+ sys.version_info < (3, 5),
+ reason='This syntax is only valid in Python 3.x',
+ )
+ def test_tuple_unpacking(self):
+ tree = ast.parse('a, *(b, c) = 1, 2, 3')
+ checker = BuiltinsChecker(tree, '/home/script.py')
+ ret = [c for c in checker.run()]
+ self.assertEqual(len(ret), 0)
+
+
+if sys.version_info >= (3, 6):
+ @given(source_code=hypothesmith.from_grammar())
+ def test_builtin_works_on_many_examples(source_code):
+ try:
+ source = source_code.encode('utf-8-sig')
+ except UnicodeEncodeError:
+ reject()
+ raise
+ tree = ast.parse(source)
+ checker = BuiltinsChecker(tree, '/home/script.py')
+ assert isinstance([c for c in checker.run()], list)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/flake8-builtins-1.4.1/setup.py
new/flake8-builtins-1.5.2/setup.py
--- old/flake8-builtins-1.4.1/setup.py 2018-05-11 11:30:04.000000000 +0200
+++ new/flake8-builtins-1.5.2/setup.py 2020-03-16 13:16:48.000000000 +0100
@@ -14,7 +14,7 @@
setup(
name='flake8-builtins',
- version='1.4.1',
+ version='1.5.2',
description=short_description,
long_description=long_description,
# Get more from https://pypi.org/pypi?%3Aaction=list_classifiers
@@ -29,8 +29,9 @@
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
- 'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
+ 'Programming Language :: Python :: 3.7',
+ 'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Topic :: Software Development',