Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package python-flake8-comprehensions for 
openSUSE:Factory checked in at 2023-04-13 15:30:49
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-flake8-comprehensions (Old)
 and      /work/SRC/openSUSE:Factory/.python-flake8-comprehensions.new.19717 
(New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-flake8-comprehensions"

Thu Apr 13 15:30:49 2023 rev:10 rq:1079170 version:3.12.0

Changes:
--------
--- 
/work/SRC/openSUSE:Factory/python-flake8-comprehensions/python-flake8-comprehensions.changes
        2023-03-21 17:44:58.250817688 +0100
+++ 
/work/SRC/openSUSE:Factory/.python-flake8-comprehensions.new.19717/python-flake8-comprehensions.changes
     2023-04-13 15:30:49.775762514 +0200
@@ -1,0 +2,9 @@
+Thu Apr 13 12:27:04 UTC 2023 - Dirk Müller <dmuel...@suse.com>
+
+- update to 3.12.0:
+  * Add rule C418 to check for calls passing a dict literal or
+    dict comprehension to ``dict()``.
+  * Add rule C419 to check for calls passing a list comprehension
+    to ``any()``/``all()``.
+
+-------------------------------------------------------------------

Old:
----
  3.11.1.tar.gz

New:
----
  3.12.0.tar.gz

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

Other differences:
------------------
++++++ python-flake8-comprehensions.spec ++++++
--- /var/tmp/diff_new_pack.rmxl14/_old  2023-04-13 15:30:50.339765746 +0200
+++ /var/tmp/diff_new_pack.rmxl14/_new  2023-04-13 15:30:50.343765769 +0200
@@ -18,7 +18,7 @@
 
 %define skip_python2 1
 Name:           python-flake8-comprehensions
-Version:        3.11.1
+Version:        3.12.0
 Release:        0
 Summary:        A flake8 plugin to help you write better list/set/dict 
comprehensions
 License:        ISC

++++++ 3.11.1.tar.gz -> 3.12.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flake8-comprehensions-3.11.1/.pre-commit-config.yaml 
new/flake8-comprehensions-3.12.0/.pre-commit-config.yaml
--- old/flake8-comprehensions-3.11.1/.pre-commit-config.yaml    2023-03-21 
15:28:53.000000000 +0100
+++ new/flake8-comprehensions-3.12.0/.pre-commit-config.yaml    2023-04-13 
11:27:27.000000000 +0200
@@ -23,6 +23,10 @@
   - id: setup-cfg-fmt
     args:
     - --include-version-classifiers
+- repo: https://github.com/tox-dev/tox-ini-fmt
+  rev: 1.3.0
+  hooks:
+  - id: tox-ini-fmt
 - repo: https://github.com/rstcheck/rstcheck
   rev: v6.1.2
   hooks:
@@ -35,7 +39,7 @@
   - id: pyupgrade
     args: [--py37-plus]
 - repo: https://github.com/psf/black
-  rev: 23.1.0
+  rev: 23.3.0
   hooks:
   - id: black
 - repo: https://github.com/adamchainz/blacken-docs
@@ -64,6 +68,6 @@
     - flake8-tidy-imports
     - flake8-typing-imports
 - repo: https://github.com/pre-commit/mirrors-mypy
-  rev: v1.1.1
+  rev: v1.2.0
   hooks:
   - id: mypy
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flake8-comprehensions-3.11.1/CHANGELOG.rst 
new/flake8-comprehensions-3.12.0/CHANGELOG.rst
--- old/flake8-comprehensions-3.11.1/CHANGELOG.rst      2023-03-21 
15:28:53.000000000 +0100
+++ new/flake8-comprehensions-3.12.0/CHANGELOG.rst      2023-04-13 
11:27:27.000000000 +0200
@@ -2,6 +2,13 @@
 Changelog
 =========
 
+3.12.0 (2023-04-13)
+-------------------
+
+* Add rule C418 to check for calls passing a dict literal or dict 
comprehension to ``dict()``.
+
+* Add rule C419 to check for calls passing a list comprehension to 
``any()``/``all()``.
+
 3.11.1 (2023-03-21)
 -------------------
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flake8-comprehensions-3.11.1/README.rst 
new/flake8-comprehensions-3.12.0/README.rst
--- old/flake8-comprehensions-3.11.1/README.rst 2023-03-21 15:28:53.000000000 
+0100
+++ new/flake8-comprehensions-3.12.0/README.rst 2023-04-13 11:27:27.000000000 
+0200
@@ -113,7 +113,7 @@
 Rules:
 
 * C409 Unnecessary ``<list/tuple>`` passed to tuple() - ``<advice>``.
-* C410 Unnecessary ``list passed to list() - ``<advice>``.
+* C410 Unnecessary list passed to list() - ``<advice>``.
 
 Where ``<advice>`` is either:
 
@@ -207,3 +207,23 @@
 * Rewrite ``list(map(lambda num: num * 2, nums))`` to ``[num * 2 for num in 
nums]``
 * Rewrite ``set(map(lambda num: num % 2 == 0, nums))`` to ``{num % 2 == 0 for 
num in nums}``
 * Rewrite ``dict(map(lambda v: (v, v ** 2), values))`` to ``{v : v ** 2 for v 
in values}``
+
+C418: Unnecessary ``<dict/dict comprehension>`` passed to dict() - remove the 
outer call to dict()
+--------------------------------------------------------------------------------------------------
+
+It's unnecessary to use a ``dict`` around a dict literal or dict 
comprehension, since either syntax already constructs a dict.
+For example:
+
+* Rewrite ``dict({})`` as ``{}``
+* Rewrite ``dict({"a": 1})`` as ``{"a": 1}``
+
+C419 Unnecessary list comprehension in ``<any/all>``\() prevents 
short-circuiting - rewrite as a generator.
+-----------------------------------------------------------------------------------------------------------
+
+Using a list comprehension inside a call to ``any()``/``all()`` prevents 
short-circuiting when a ``True`` / ``False`` value is found.
+The whole list will be constructed before calling ``any()``/``all()``, 
potentially wasting work.part-way.
+Rewrite to use a generator expression, which can stop part way.
+For example:
+
+* Rewrite ``all([condition(x) for x in iterable])`` as ``all(condition(x) for 
x in iterable)``
+* Rewrite ``any([condition(x) for x in iterable])`` as ``any(condition(x) for 
x in iterable)``
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flake8-comprehensions-3.11.1/requirements/py310.txt 
new/flake8-comprehensions-3.12.0/requirements/py310.txt
--- old/flake8-comprehensions-3.11.1/requirements/py310.txt     2023-03-21 
15:28:53.000000000 +0100
+++ new/flake8-comprehensions-3.12.0/requirements/py310.txt     2023-04-13 
11:27:27.000000000 +0200
@@ -8,9 +8,9 @@
     
--hash=sha256:29e95c7f6778868dbd49170f98f8818f78f3dc5e0e37c0b1f474e3561b240836 \
     
--hash=sha256:c9227bfc2f01993c03f68db37d1d15c9690188323c067c641f1a35ca58185f99
     # via pytest
-exceptiongroup==1.1.0 \
-    
--hash=sha256:327cbda3da756e2de031a3107b81ab7b3770a602c4d16ca618298c526f4bec1e \
-    
--hash=sha256:bcb67d800a4497e1b404c2dd44fca47d3b7a5e5433dbab67f96c1a685cdfdf23
+exceptiongroup==1.1.1 \
+    
--hash=sha256:232c37c63e4f682982c8b6459f33a8981039e5fb8756b2074364e5055c498c9e \
+    
--hash=sha256:d484c3090ba2889ae2928419117447a14daf3c1231d5e30d0aae34f354f01785
     # via pytest
 flake8==6.0.0 \
     
--hash=sha256:3833794e27ff64ea4e9cf5d410082a8b97ff1a06c16aa3d2027339cd0f1195c7 \
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flake8-comprehensions-3.11.1/requirements/py37.txt 
new/flake8-comprehensions-3.12.0/requirements/py37.txt
--- old/flake8-comprehensions-3.11.1/requirements/py37.txt      2023-03-21 
15:28:53.000000000 +0100
+++ new/flake8-comprehensions-3.12.0/requirements/py37.txt      2023-04-13 
11:27:27.000000000 +0200
@@ -8,9 +8,9 @@
     
--hash=sha256:29e95c7f6778868dbd49170f98f8818f78f3dc5e0e37c0b1f474e3561b240836 \
     
--hash=sha256:c9227bfc2f01993c03f68db37d1d15c9690188323c067c641f1a35ca58185f99
     # via pytest
-exceptiongroup==1.1.0 \
-    
--hash=sha256:327cbda3da756e2de031a3107b81ab7b3770a602c4d16ca618298c526f4bec1e \
-    
--hash=sha256:bcb67d800a4497e1b404c2dd44fca47d3b7a5e5433dbab67f96c1a685cdfdf23
+exceptiongroup==1.1.1 \
+    
--hash=sha256:232c37c63e4f682982c8b6459f33a8981039e5fb8756b2074364e5055c498c9e \
+    
--hash=sha256:d484c3090ba2889ae2928419117447a14daf3c1231d5e30d0aae34f354f01785
     # via pytest
 flake8==5.0.4 \
     
--hash=sha256:6fbe320aad8d6b95cec8b8e47bc933004678dc63095be98528b7bdd2a9f510db \
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flake8-comprehensions-3.11.1/requirements/py38.txt 
new/flake8-comprehensions-3.12.0/requirements/py38.txt
--- old/flake8-comprehensions-3.11.1/requirements/py38.txt      2023-03-21 
15:28:53.000000000 +0100
+++ new/flake8-comprehensions-3.12.0/requirements/py38.txt      2023-04-13 
11:27:27.000000000 +0200
@@ -8,17 +8,17 @@
     
--hash=sha256:29e95c7f6778868dbd49170f98f8818f78f3dc5e0e37c0b1f474e3561b240836 \
     
--hash=sha256:c9227bfc2f01993c03f68db37d1d15c9690188323c067c641f1a35ca58185f99
     # via pytest
-exceptiongroup==1.1.0 \
-    
--hash=sha256:327cbda3da756e2de031a3107b81ab7b3770a602c4d16ca618298c526f4bec1e \
-    
--hash=sha256:bcb67d800a4497e1b404c2dd44fca47d3b7a5e5433dbab67f96c1a685cdfdf23
+exceptiongroup==1.1.1 \
+    
--hash=sha256:232c37c63e4f682982c8b6459f33a8981039e5fb8756b2074364e5055c498c9e \
+    
--hash=sha256:d484c3090ba2889ae2928419117447a14daf3c1231d5e30d0aae34f354f01785
     # via pytest
 flake8==6.0.0 \
     
--hash=sha256:3833794e27ff64ea4e9cf5d410082a8b97ff1a06c16aa3d2027339cd0f1195c7 \
     
--hash=sha256:c61007e76655af75e6785a931f452915b371dc48f56efd765247c8fe68f2b181
     # via pytest-flake8-path
-importlib-metadata==6.0.0 \
-    
--hash=sha256:7efb448ec9a5e313a57655d35aa54cd3e01b7e1fbcf72dce1bf06119420f5bad \
-    
--hash=sha256:e354bedeb60efa6affdcc8ae121b73544a7aa74156d047311948f6d711cd378d
+importlib-metadata==6.2.0 \
+    
--hash=sha256:8388b74023a138c605fddd0d47cb81dd706232569f56c9aca7d9c7fdb54caeba \
+    
--hash=sha256:9127aad2f49d7203e7112098c12b92e4fd1061ccd18548cdfdc49171a8c073cc
     # via pytest-randomly
 iniconfig==2.0.0 \
     
--hash=sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3 \
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flake8-comprehensions-3.11.1/requirements/py39.txt 
new/flake8-comprehensions-3.12.0/requirements/py39.txt
--- old/flake8-comprehensions-3.11.1/requirements/py39.txt      2023-03-21 
15:28:53.000000000 +0100
+++ new/flake8-comprehensions-3.12.0/requirements/py39.txt      2023-04-13 
11:27:27.000000000 +0200
@@ -8,17 +8,17 @@
     
--hash=sha256:29e95c7f6778868dbd49170f98f8818f78f3dc5e0e37c0b1f474e3561b240836 \
     
--hash=sha256:c9227bfc2f01993c03f68db37d1d15c9690188323c067c641f1a35ca58185f99
     # via pytest
-exceptiongroup==1.1.0 \
-    
--hash=sha256:327cbda3da756e2de031a3107b81ab7b3770a602c4d16ca618298c526f4bec1e \
-    
--hash=sha256:bcb67d800a4497e1b404c2dd44fca47d3b7a5e5433dbab67f96c1a685cdfdf23
+exceptiongroup==1.1.1 \
+    
--hash=sha256:232c37c63e4f682982c8b6459f33a8981039e5fb8756b2074364e5055c498c9e \
+    
--hash=sha256:d484c3090ba2889ae2928419117447a14daf3c1231d5e30d0aae34f354f01785
     # via pytest
 flake8==6.0.0 \
     
--hash=sha256:3833794e27ff64ea4e9cf5d410082a8b97ff1a06c16aa3d2027339cd0f1195c7 \
     
--hash=sha256:c61007e76655af75e6785a931f452915b371dc48f56efd765247c8fe68f2b181
     # via pytest-flake8-path
-importlib-metadata==6.0.0 \
-    
--hash=sha256:7efb448ec9a5e313a57655d35aa54cd3e01b7e1fbcf72dce1bf06119420f5bad \
-    
--hash=sha256:e354bedeb60efa6affdcc8ae121b73544a7aa74156d047311948f6d711cd378d
+importlib-metadata==6.2.0 \
+    
--hash=sha256:8388b74023a138c605fddd0d47cb81dd706232569f56c9aca7d9c7fdb54caeba \
+    
--hash=sha256:9127aad2f49d7203e7112098c12b92e4fd1061ccd18548cdfdc49171a8c073cc
     # via pytest-randomly
 iniconfig==2.0.0 \
     
--hash=sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3 \
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flake8-comprehensions-3.11.1/setup.cfg 
new/flake8-comprehensions-3.12.0/setup.cfg
--- old/flake8-comprehensions-3.11.1/setup.cfg  2023-03-21 15:28:53.000000000 
+0100
+++ new/flake8-comprehensions-3.12.0/setup.cfg  2023-04-13 11:27:27.000000000 
+0200
@@ -1,6 +1,6 @@
 [metadata]
 name = flake8_comprehensions
-version = 3.11.1
+version = 3.12.0
 description = A flake8 plugin to help you write better list/set/dict 
comprehensions.
 long_description = file: README.rst
 long_description_content_type = text/x-rst
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/flake8-comprehensions-3.11.1/src/flake8_comprehensions/__init__.py 
new/flake8-comprehensions-3.12.0/src/flake8_comprehensions/__init__.py
--- old/flake8-comprehensions-3.11.1/src/flake8_comprehensions/__init__.py      
2023-03-21 15:28:53.000000000 +0100
+++ new/flake8-comprehensions-3.12.0/src/flake8_comprehensions/__init__.py      
2023-04-13 11:27:27.000000000 +0200
@@ -43,6 +43,14 @@
         "C415": "C415 Unnecessary subscript reversal of iterable within 
{func}().",
         "C416": "C416 Unnecessary {type} comprehension - rewrite using 
{type}().",
         "C417": "C417 Unnecessary use of map - use a {comp} instead.",
+        "C418": (
+            "C418 Unnecessary {type} passed to dict() - "
+            + "remove the outer call to dict()."
+        ),
+        "C419": (
+            "C419 Unnecessary list comprehension passed to {func}() prevents "
+            + "short-circuiting - rewrite as a generator."
+        ),
     }
 
     def run(self) -> Generator[tuple[int, int, str, type[Any]], None, None]:
@@ -89,13 +97,19 @@
                 elif (
                     num_positional_args == 1
                     and isinstance(node.args[0], ast.ListComp)
-                    and node.func.id in ("list", "set")
+                    and node.func.id in ("list", "set", "any", "all")
                 ):
-                    msg_key = {"list": "C411", "set": "C403"}[node.func.id]
+                    msg_key = {
+                        "list": "C411",
+                        "set": "C403",
+                        "any": "C419",
+                        "all": "C419",
+                    }[node.func.id]
+                    msg = self.messages[msg_key].format(func=node.func.id)
                     yield (
                         node.lineno,
                         node.col_offset,
-                        self.messages[msg_key],
+                        msg,
                         type(self),
                     )
 
@@ -117,6 +131,23 @@
                         type(self),
                     )
 
+                elif (
+                    num_positional_args == 1
+                    and num_keyword_args == 0
+                    and isinstance(node.args[0], (ast.Dict, ast.DictComp))
+                    and node.func.id == "dict"
+                ):
+                    if isinstance(node.args[0], ast.Dict):
+                        type_ = "dict"
+                    else:
+                        type_ = "dict comprehension"
+                    yield (
+                        node.lineno,
+                        node.col_offset,
+                        self.messages["C418"].format(type=type_),
+                        type(self),
+                    )
+
                 elif (
                     num_positional_args == 1
                     and isinstance(node.args[0], (ast.Tuple, ast.List))
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/flake8-comprehensions-3.11.1/tests/test_flake8_comprehensions.py 
new/flake8-comprehensions-3.12.0/tests/test_flake8_comprehensions.py
--- old/flake8-comprehensions-3.11.1/tests/test_flake8_comprehensions.py        
2023-03-21 15:28:53.000000000 +0100
+++ new/flake8-comprehensions-3.12.0/tests/test_flake8_comprehensions.py        
2023-04-13 11:27:27.000000000 +0200
@@ -893,3 +893,86 @@
     (flake8_path / "example.py").write_text(dedent(code))
     result = flake8_path.run_flake8()
     assert result.out_lines == failures
+
+
+@pytest.mark.parametrize(
+    "code",
+    [
+        "dict({}, a=1)",
+        "dict({x: 1 for x in range(1)}, a=1)",
+    ],
+)
+def test_C418_pass(code, flake8_path):
+    (flake8_path / "example.py").write_text(dedent(code))
+    result = flake8_path.run_flake8()
+    assert result.out_lines == []
+
+
+@pytest.mark.parametrize(
+    "code,failures",
+    [
+        (
+            "dict({})",
+            [
+                "./example.py:1:1: C418 Unnecessary dict passed to dict() - "
+                + "remove the outer call to dict()."
+            ],
+        ),
+        (
+            "dict({'a': 1})",
+            [
+                "./example.py:1:1: C418 Unnecessary dict passed to dict() - "
+                + "remove the outer call to dict()."
+            ],
+        ),
+        (
+            "dict({'x': 1 for x in range(10)})",
+            [
+                "./example.py:1:1: C418 Unnecessary dict comprehension passed "
+                + "to dict() - remove the outer call to dict()."
+            ],
+        ),
+    ],
+)
+def test_C418_fail(code, failures, flake8_path):
+    (flake8_path / "example.py").write_text(dedent(code))
+    result = flake8_path.run_flake8()
+    assert result.out_lines == failures
+
+
+@pytest.mark.parametrize(
+    "code",
+    [
+        "any(num == 3 for num in range(5))",
+        "all(num == 3 for num in range(5))",
+    ],
+)
+def test_C419_pass(code, flake8_path):
+    (flake8_path / "example.py").write_text(dedent(code))
+    result = flake8_path.run_flake8()
+    assert result.out_lines == []
+
+
+@pytest.mark.parametrize(
+    "code,failures",
+    [
+        (
+            "any([num == 3 for num in range(5)])",
+            [
+                "./example.py:1:1: C419 Unnecessary list comprehension passed "
+                + "to any() prevents short-circuiting - rewrite as a 
generator."
+            ],
+        ),
+        (
+            "all([num == 3 for num in range(5)])",
+            [
+                "./example.py:1:1: C419 Unnecessary list comprehension passed "
+                + "to all() prevents short-circuiting - rewrite as a 
generator."
+            ],
+        ),
+    ],
+)
+def test_C419_fail(code, failures, flake8_path):
+    (flake8_path / "example.py").write_text(dedent(code))
+    result = flake8_path.run_flake8()
+    assert result.out_lines == failures
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flake8-comprehensions-3.11.1/tox.ini 
new/flake8-comprehensions-3.12.0/tox.ini
--- old/flake8-comprehensions-3.11.1/tox.ini    2023-03-21 15:28:53.000000000 
+0100
+++ new/flake8-comprehensions-3.12.0/tox.ini    2023-04-13 11:27:27.000000000 
+0200
@@ -1,14 +1,17 @@
 [tox]
-envlist =
-    py{37,38,39,310,311}
+requires =
+    tox>=4.2
+env_list =
+    py{311, 310, 39, 38, 37}
 
 [testenv]
+deps =
+    -r requirements/{envname}.txt
+set_env =
+    PYTHONDEVMODE = 1
 commands =
-  python \
-    -W error::ResourceWarning \
-    -W error::DeprecationWarning \
-    -W error::PendingDeprecationWarning \
-    -m pytest {posargs:tests}
-deps = -r requirements/{envname}.txt
-setenv =
-    PYTHONDEVMODE=1
+    python \
+      -W error::ResourceWarning \
+      -W error::DeprecationWarning \
+      -W error::PendingDeprecationWarning \
+      -m pytest {posargs:tests}

Reply via email to