D7700: import-checker: allow all absolute imports of stdlib modules

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Mon Dec 23 12:27:33 EST 2019


Closed by commit rHG303576116ac1: import-checker: allow all absolute imports of stdlib modules (authored by martinvonz).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7700?vs=18867&id=18913

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7700/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D7700

AFFECTED FILES
  contrib/import-checker.py
  tests/test-imports-checker.t

CHANGE DETAILS

diff --git a/tests/test-imports-checker.t b/tests/test-imports-checker.t
--- a/tests/test-imports-checker.t
+++ b/tests/test-imports-checker.t
@@ -47,6 +47,11 @@
   > from .. import os
   > EOF
 
+  $ cat > testpackage/stdlibfrom.py << EOF
+  > from __future__ import absolute_import
+  > from collections import abc
+  > EOF
+
   $ cat > testpackage/symbolimport.py << EOF
   > from __future__ import absolute_import
   > from .unsorted import foo
@@ -150,6 +155,7 @@
   testpackage/requirerelative.py:2: import should be relative: testpackage.unsorted
   testpackage/sortedentries.py:2: imports from testpackage not lexically sorted: bar < foo
   testpackage/stdafterlocal.py:3: stdlib import "os" follows local import: testpackage
+  testpackage/stdlibfrom.py:2: direct symbol import abc from collections
   testpackage/subpackage/levelpriority.py:3: higher-level import should come first: testpackage
   testpackage/subpackage/localimport.py:7: multiple "from .. import" statements
   testpackage/subpackage/localimport.py:8: import should be relative: testpackage.subpackage.levelpriority
diff --git a/contrib/import-checker.py b/contrib/import-checker.py
--- a/contrib/import-checker.py
+++ b/contrib/import-checker.py
@@ -536,7 +536,7 @@
                 if not fullname or (
                     fullname in stdlib_modules
                     # allow standard 'from typing import ...' style
-                    and fullname != 'typing'
+                    and fullname.startswith('.')
                     and fullname not in localmods
                     and fullname + '.__init__' not in localmods
                 ):



To: martinvonz, #hg-reviewers, indygreg
Cc: mercurial-devel


More information about the Mercurial-devel mailing list