Skip to content

Pytype fails on MacOSX(Mojave-10.14.9) when inferring types.  #661

@maldil

Description

@maldil

Hello,

I am trying to execute Pytype in a project as below.

pytype --pythonpath=./$PROJECT_DIRECTORY --no-report-errors $PROJECT_DIRECTORY

What I need is to run Pytype over a project (first step) and then use AST annotator to get type information of variables in a file. When I run above command it gives me the following error.

[2/154] infer pymc3.backends.HDF5
FAILED: /Users/user_name/Documents/Research_Topic_2/PytypeTest/.pytype/pyi/pymc3/backends/HDF5.pyi 
/Users/user_name/Documents/Research_Topic_2/VMS/pytestenv/bin/python -m pytype.single --imports_info /Users/user_name/Documents/Research_Topic_2/PytypeTest/.pytype/imports/pymc3.backends.HDF5.imports --module-name pymc3.backends.HDF5 -V 3.7 -o /Users/user_name/Documents/Research_Topic_2/PytypeTest/.pytype/pyi/pymc3/backends/HDF5.pyi --no-report-errors --nofail --quick /Users/user_name/Documents/Research_Topic_2/PytypeTest/pymc3-master/pymc3/backends/HDF5.py
ERROR:pytype.imports_map_loader Invalid imports_map entries (checking from root dir: /Users/user_name/Documents/Research_Topic_2/PytypeTest/.pytype)
ERROR:pytype.imports_map_loader   file does not exist: '/Users/user_name/Documents/Research_Topic_2/PytypeTest/.pytype/pyi/pymc3/backends/HDF5.pyi' (mapped from 'pymc3/backends/HDF5')
ERROR:pytype.imports_map_loader   file does not exist: '/Users/user_name/Documents/Research_Topic_2/PytypeTest/.pytype/pyi/pymc3/backends/NDArray.pyi' (mapped from 'pymc3/backends/NDArray')
ERROR:pytype.imports_map_loader   file does not exist: '/Users/user_name/Documents/Research_Topic_2/PytypeTest/.pytype/pyi/pymc3/backends/SQLite.pyi' (mapped from 'pymc3/backends/SQLite')
ERROR:pytype.imports_map_loader   file does not exist: '/Users/user_name/Documents/Research_Topic_2/PytypeTest/.pytype/pyi/pymc3/backends/Text.pyi' (mapped from 'pymc3/backends/Text')
ERROR:pytype.imports_map_loader   file does not exist: '/Users/user_name/Documents/Research_Topic_2/PytypeTest/.pytype/pyi/pymc3/backends/__init__.pyi' (mapped from 'pymc3/backends/__init__')
ERROR:pytype.imports_map_loader   file does not exist: '/Users/user_name/Documents/Research_Topic_2/PytypeTest/.pytype/pyi/pymc3/backends/base.pyi' (mapped from 'pymc3/backends/base')
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/Users/user_name/Documents/Research_Topic_2/VMS/pytestenv/lib/python3.7/site-packages/pytype/single.py", line 103, in <module>
    sys.exit(main() or 0)
  File "/Users/user_name/Documents/Research_Topic_2/VMS/pytestenv/lib/python3.7/site-packages/pytype/single.py", line 66, in main
    options = config.Options(sys.argv[1:])
  File "/Users/user_name/Documents/Research_Topic_2/VMS/pytestenv/lib/python3.7/site-packages/pytype/config.py", line 54, in __init__
    Postprocessor(names, options, self).process()
  File "/Users/user_name/Documents/Research_Topic_2/VMS/pytestenv/lib/python3.7/site-packages/pytype/config.py", line 392, in process
    node.processor(value)
  File "/Users/user_name/Documents/Research_Topic_2/VMS/pytestenv/lib/python3.7/site-packages/pytype/config.py", line 550, in _store_imports_map
    imports_map, self.output_options.output)
  File "/Users/user_name/Documents/Research_Topic_2/VMS/pytestenv/lib/python3.7/site-packages/pytype/imports_map_loader.py", line 90, in build_imports_map
    raise ValueError(msg)
ValueError: Invalid imports_map: /Users/user_name/Documents/Research_Topic_2/PytypeTest/.pytype/imports/pymc3.backends.HDF5.imports
Bad entries:
  pymc3/backends/HDF5 -> /Users/user_name/Documents/Research_Topic_2/PytypeTest/.pytype/pyi/pymc3/backends/HDF5.pyi
  pymc3/backends/NDArray -> /Users/user_name/Documents/Research_Topic_2/PytypeTest/.pytype/pyi/pymc3/backends/NDArray.pyi
  pymc3/backends/SQLite -> /Users/user_name/Documents/Research_Topic_2/PytypeTest/.pytype/pyi/pymc3/backends/SQLite.pyi
  pymc3/backends/Text -> /Users/user_name/Documents/Research_Topic_2/PytypeTest/.pytype/pyi/pymc3/backends/Text.pyi
  pymc3/backends/__init__ -> /Users/user_name/Documents/Research_Topic_2/PytypeTest/.pytype/pyi/pymc3/backends/__init__.pyi
  pymc3/backends/base -> /Users/user_name/Documents/Research_Topic_2/PytypeTest/.pytype/pyi/pymc3/backends/base.pyi

Steps to reproduce

  1. Clone https://github.com/pymc-devs/pymc3
  2. Run pytype --pythonpath=./$PROJECT_DIRECTORY --no-report-errors $PROJECT_DIRECTORY
    (Pytype version = 2020.08.17, OS version = macOS Mojave-10.14.9)

Questions

  1. Do you have any idea on the above error?
  2. Suppose that, I want to run Pytype without failing. I observed two options (--nofail and --return-success) in the configuration file . When I try to run pytype with these two options, pytype does not identify the options. It says pytype: error: unrecognized arguments: --nofail. What could be the reason for these errors and what options should I use to run Pytype without failing?

The command that I tried is
pytype --pythonpath=$PROJECT_DIRECTORY --no-report-errors --nofail $PROJECT_DIRECTORY
Thank you in advance.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions