Mercurial > hg
comparison contrib/import-checker.py @ 43954:303576116ac1
import-checker: allow all absolute imports of stdlib modules
Before this patch, we didn't allow imports like
from importlib import resources
(That's the reason I used `import importlib.resources` in D7629.)
I think that form is still an absolute import, so I don't think we
forbade on purpose.
Differential Revision: https://phab.mercurial-scm.org/D7700
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Wed, 18 Dec 2019 13:39:44 -0800 |
parents | 0ad5d6c4bfad |
children | 4cabeea6d214 |
comparison
equal
deleted
inserted
replaced
43953:d825e7e0ca6e | 43954:303576116ac1 |
---|---|
534 # symbol import. | 534 # symbol import. |
535 if fullname != '__future__': | 535 if fullname != '__future__': |
536 if not fullname or ( | 536 if not fullname or ( |
537 fullname in stdlib_modules | 537 fullname in stdlib_modules |
538 # allow standard 'from typing import ...' style | 538 # allow standard 'from typing import ...' style |
539 and fullname != 'typing' | 539 and fullname.startswith('.') |
540 and fullname not in localmods | 540 and fullname not in localmods |
541 and fullname + '.__init__' not in localmods | 541 and fullname + '.__init__' not in localmods |
542 ): | 542 ): |
543 yield msg('relative import of stdlib module') | 543 yield msg('relative import of stdlib module') |
544 else: | 544 else: |