Patchwork import-checker: allow 'from typing import ...'

login
register
mail settings
Submitter Yuya Nishihara
Date Nov. 11, 2019, 1:20 p.m.
Message ID <80b0f402de043fb9dc53.1573478404@mimosa>
Download mbox | patch
Permalink /patch/43120/
State Accepted
Headers show

Comments

Yuya Nishihara - Nov. 11, 2019, 1:20 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1573477826 -32400
#      Mon Nov 11 22:10:26 2019 +0900
# Node ID 80b0f402de043fb9dc5393928e04a2c01b2c3423
# Parent  ecd11c4d3834b7602d9bdc6f27ba1f4fc07911a1
import-checker: allow 'from typing import ...'

Suppresses the following error in test-check-module-imports.t:

  mercurial/encoding.py:24: relative import of stdlib module
Augie Fackler - Nov. 11, 2019, 3:51 p.m.
queued, many thanks

> On Nov 11, 2019, at 08:20, Yuya Nishihara <yuya@tcha.org> wrote:
> 
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1573477826 -32400
> #      Mon Nov 11 22:10:26 2019 +0900
> # Node ID 80b0f402de043fb9dc5393928e04a2c01b2c3423
> # Parent  ecd11c4d3834b7602d9bdc6f27ba1f4fc07911a1
> import-checker: allow 'from typing import ...'
> 
> Suppresses the following error in test-check-module-imports.t:
> 
>  mercurial/encoding.py:24: relative import of stdlib module
> 
> diff --git a/contrib/import-checker.py b/contrib/import-checker.py
> --- a/contrib/import-checker.py
> +++ b/contrib/import-checker.py
> @@ -535,6 +535,8 @@ def verify_modern_convention(module, roo
>             if fullname != '__future__':
>                 if not fullname or (
>                     fullname in stdlib_modules
> +                    # allow standard 'from typing import ...' style
> +                    and fullname != 'typing'
>                     and fullname not in localmods
>                     and fullname + '.__init__' not in localmods
>                 ):
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/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
@@ -535,6 +535,8 @@  def verify_modern_convention(module, roo
             if fullname != '__future__':
                 if not fullname or (
                     fullname in stdlib_modules
+                    # allow standard 'from typing import ...' style
+                    and fullname != 'typing'
                     and fullname not in localmods
                     and fullname + '.__init__' not in localmods
                 ):