Patchwork D12365: import-checker: allow symbol imports from typing module

login
register
mail settings
Submitter phabricator
Date March 10, 2022, 1:08 a.m.
Message ID <differential-rev-PHID-DREV-3i6thuuymjm2frtzndt5-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/50707/
State New
Headers show

Comments

phabricator - March 10, 2022, 1:08 a.m.
indygreg created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  As we add typing annotations, we'll want to use a lot of symbols from
  the `typing` module. Typing `typing` all the time will be annoying. Let's
  allow symbol imports from this module.
  
  While I was here, I changed some comments from "whitelist" to "allow list"
  as the former is non-inclusive terminology.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  contrib/import-checker.py

CHANGE DETAILS




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

Patch

diff --git a/contrib/import-checker.py b/contrib/import-checker.py
--- a/contrib/import-checker.py
+++ b/contrib/import-checker.py
@@ -19,7 +19,7 @@ 
 
 import testparseutil
 
-# Whitelist of modules that symbols can be directly imported from.
+# Allow list of modules that symbols can be directly imported from.
 allowsymbolimports = (
     '__future__',
     'breezy',
@@ -46,9 +46,10 @@ 
     'mercurial.thirdparty.attr',
     'mercurial.thirdparty.zope',
     'mercurial.thirdparty.zope.interface',
+    'typing',
 )
 
-# Whitelist of symbols that can be directly imported.
+# Allow list of symbols that can be directly imported.
 directsymbols = ('demandimport',)
 
 # Modules that must be aliased because they are commonly confused with