Patchwork D7410: extensions: suppress a strange pytype failure

login
register
mail settings
Submitter phabricator
Date Nov. 14, 2019, 9:12 p.m.
Message ID <differential-rev-PHID-DREV-igfgmlefe6jtfrvb654i-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/43215/
State Superseded
Headers show

Comments

phabricator - Nov. 14, 2019, 9:12 p.m.
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  I suspect a bug in pytype here, but I'll follow up with that later. We
  have good enough coverage on this that I'm happy to move on for now.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/extensions.py

CHANGE DETAILS




To: durin42, #hg-reviewers
Cc: mercurial-devel
phabricator - Nov. 15, 2019, 2:02 p.m.
dlax added inline comments.
dlax accepted this revision.

INLINE COMMENTS

> extensions.py:96
> +        # pytype seems to think `fd` is a str, but I'm pretty sure
> +        # it's wrong. This may be a bug we need to report upstream.
> +        return imp.load_module(

the doc indeed says that "fd" is file object

REPOSITORY
  rHG Mercurial

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

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

To: durin42, #hg-reviewers, dlax
Cc: dlax, mercurial-devel
phabricator - Nov. 15, 2019, 2:46 p.m.
dlax added inline comments.

INLINE COMMENTS

> dlax wrote in extensions.py:96
> the doc indeed says that "fd" is file object

In https://github.com/python/typeshed/blob/master/stdlib/3/imp.pyi type of `find_module` seems wrong.

REPOSITORY
  rHG Mercurial

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

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

To: durin42, #hg-reviewers, dlax
Cc: dlax, mercurial-devel
phabricator - Nov. 15, 2019, 5:49 p.m.
dlax added a comment.
dlax accepted this revision.


  meanwhile, https://github.com/python/typeshed/pull/3465

REPOSITORY
  rHG Mercurial

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

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

To: durin42, #hg-reviewers, dlax
Cc: dlax, mercurial-devel

Patch

diff --git a/mercurial/extensions.py b/mercurial/extensions.py
--- a/mercurial/extensions.py
+++ b/mercurial/extensions.py
@@ -92,7 +92,11 @@ 
         # module/__init__.py style
         d, f = os.path.split(path)
         fd, fpath, desc = imp.find_module(f, [d])
-        return imp.load_module(module_name, fd, fpath, desc)
+        # pytype seems to think `fd` is a str, but I'm pretty sure
+        # it's wrong. This may be a bug we need to report upstream.
+        return imp.load_module(
+            module_name, fd, fpath, desc  # pytype: disable=wrong-arg-types
+        )
     else:
         try:
             return imp.load_source(module_name, path)