Nilesh Patra pushed to branch master at lintian / lintian


Commits:
69861ea9 by Louis-Philippe Véronneau at 2024-07-31T14:43:17+00:00
Fix false-positive for uses-deprecated-python-stdlib tag

Closes: #1077324

- - - - -


6 changed files:

- lib/Lintian/Check/Languages/Python/StdlibDeprecation.pm
- 
t/recipes/checks/languages/python/stdlib-deprecation/python-imports-asyncore/build-spec/orig/from.py
- 
t/recipes/checks/languages/python/stdlib-deprecation/python-imports-asyncore/build-spec/orig/import.py
- 
t/recipes/checks/languages/python/stdlib-deprecation/python-imports-asyncore/eval/hints
- 
t/recipes/checks/languages/python/stdlib-deprecation/python-imports-distutils/build-spec/orig/import.py
- 
t/recipes/checks/languages/python/stdlib-deprecation/python-imports-distutils/eval/hints


Changes:

=====================================
lib/Lintian/Check/Languages/Python/StdlibDeprecation.pm
=====================================
@@ -94,7 +94,19 @@ sub visit_patched_files {
                 $pointer,
                 $library,
 "(deprecated in Python $deprecated, removed in Python $removed)"
-            ) if $line =~ m{from $library} || $line =~ m{import $library};
+              )
+              # from library import foo
+              # from library.sub import foo
+              # this also won't match "from library2"
+              if $line =~ m{^from $library(\s||\..+ import)}
+              # import foo, library, bar
+              ||$line =~ m{^import.+$library,}
+              # import library
+              # import library.sub
+              # import foo, library
+              # import foo, library.sub
+              # import foo, library.sub, bar
+              ||$line =~ m{^import.+$library(,||\..+)?$};
         }
 
     }continue {


=====================================
t/recipes/checks/languages/python/stdlib-deprecation/python-imports-asyncore/build-spec/orig/from.py
=====================================
@@ -1,4 +1,7 @@
 #!/usr/bin/python3
 
+from asyncore import socket_map
+
+# This should not trigger the uses-deprecated-python-stdlib tag
 from ..server.asyncserver import asyncore, RequestHandler, loop, AsyncServer, 
AsyncServerException
 from supervisor.medusa import asyncore_25 as asyncore


=====================================
t/recipes/checks/languages/python/stdlib-deprecation/python-imports-asyncore/build-spec/orig/import.py
=====================================
@@ -1,3 +1,5 @@
 #!/usr/bin/python3
 
 import asyncore
+import struct, socket, argparse, asyncore
+import struct, asyncore, argparse


=====================================
t/recipes/checks/languages/python/stdlib-deprecation/python-imports-asyncore/eval/hints
=====================================
@@ -1,3 +1,4 @@
+python-imports-asyncore (source): uses-deprecated-python-stdlib asyncore 
(deprecated in Python 3.6, removed in Python 3.12) [import.py:5]
+python-imports-asyncore (source): uses-deprecated-python-stdlib asyncore 
(deprecated in Python 3.6, removed in Python 3.12) [import.py:4]
 python-imports-asyncore (source): uses-deprecated-python-stdlib asyncore 
(deprecated in Python 3.6, removed in Python 3.12) [import.py:3]
-python-imports-asyncore (source): uses-deprecated-python-stdlib asyncore 
(deprecated in Python 3.6, removed in Python 3.12) [from.py:4]
 python-imports-asyncore (source): uses-deprecated-python-stdlib asyncore 
(deprecated in Python 3.6, removed in Python 3.12) [from.py:3]


=====================================
t/recipes/checks/languages/python/stdlib-deprecation/python-imports-distutils/build-spec/orig/import.py
=====================================
@@ -1,3 +1,8 @@
 #!/usr/bin/python3
 
 import distutils
+import foo, bar, distutils.core
+import foo, distutils.core, bara
+
+# This should not match the uses-deprecated-python-stdlib tag
+import distutils2


=====================================
t/recipes/checks/languages/python/stdlib-deprecation/python-imports-distutils/eval/hints
=====================================
@@ -1,2 +1,4 @@
+python-imports-distutils (source): uses-deprecated-python-stdlib distutils 
(deprecated in Python 3.10, removed in Python 3.12) [import.py:5]
+python-imports-distutils (source): uses-deprecated-python-stdlib distutils 
(deprecated in Python 3.10, removed in Python 3.12) [import.py:4]
 python-imports-distutils (source): uses-deprecated-python-stdlib distutils 
(deprecated in Python 3.10, removed in Python 3.12) [import.py:3]
 python-imports-distutils (source): uses-deprecated-python-stdlib distutils 
(deprecated in Python 3.10, removed in Python 3.12) [from.py:7]



View it on GitLab: 
https://salsa.debian.org/lintian/lintian/-/commit/69861ea975e5e445a95d16d30cfe4a90a4f6ad1d

-- 
View it on GitLab: 
https://salsa.debian.org/lintian/lintian/-/commit/69861ea975e5e445a95d16d30cfe4a90a4f6ad1d
You're receiving this email because of your account on salsa.debian.org.


Reply via email to