jaraco / pip-run

pip-run - dynamic dependency loader for Python
MIT License
136 stars 19 forks source link

pip_run.read-deps fails with "type object 'DepsReader' has no attribute 'load'" #46

Closed jwodder closed 3 years ago

jwodder commented 3 years ago

Currently, as of v8.2.0, trying to run python3 -m pip_run.read-deps on a script with __requires__ fails with the following error:

Traceback (most recent call last):
  File "/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/python3.9/site-packages/pip_run/read-deps.py", line 16, in <module>
    __name__ == '__main__' and run()
  File "/usr/local/lib/python3.9/site-packages/pip_run/read-deps.py", line 12, in run
    deps = DepsReader.load(script).read()
AttributeError: type object 'DepsReader' has no attribute 'load'

This failure appears to be due to read-deps.py not having been updated after DepsReader.load was split out into SourceDepsReader in commit f943b56.

jaraco commented 3 years ago

Thanks for reporting this issue. I just stumbled on it today as well.

It's annoying that mypy seems perfectly satisfied with that implementation.

pip-run master $ tox -- -k read-deps -p 'no:cov' -v
python develop-inst-noop: /Users/jaraco/code/main/pip-run
python installed: appdirs==1.4.4,attrs==20.3.0,black==20.8b1,click==7.1.2,coverage==5.3,docutils==0.16,filelock==3.0.12,flake8==3.8.4,iniconfig==1.1.1,ipython-genutils==0.2.0,jaraco.apt==2.0,jaraco.classes==3.1.0,jaraco.collections==3.0.0,jaraco.context==3.0.0,jaraco.functools==3.0.1,jaraco.test==3.2.0,jaraco.text==3.2.0,jsonschema==3.2.0,jupyter-core==4.7.0,mccabe==0.6.1,more-itertools==8.6.0,mypy==0.790,mypy-extensions==0.4.3,nbformat==5.0.8,packaging==20.4,pathspec==0.8.1,-e git+gh://jaraco/pip-run@2cd2df0759fb5b2f656f2c69548a5c9239dc8dd5#egg=pip_run,pluggy==0.13.1,py==1.9.0,pycodestyle==2.6.0,pyflakes==2.2.0,pyparsing==2.4.7,pyrsistent==0.17.3,pytest==6.1.2,pytest-black==0.3.12,pytest-checkdocs==2.1.1,pytest-cov==2.10.1,pytest-flake8==1.0.6,pytest-mypy==0.8.0,pytz==2020.4,regex==2020.11.13,six==1.15.0,tempora==4.0.1,toml==0.10.2,traitlets==5.0.5,typed-ast==1.4.1,typing-extensions==3.7.4.3,yg.lockfile==2.3,zc.lockfile==2.0
python run-test-pre: PYTHONHASHSEED='4095286173'
python run-test: commands[0] | pytest -k read-deps -p no:cov -v
======================================================= test session starts ========================================================
platform darwin -- Python 3.9.0, pytest-6.1.2, py-1.9.0, pluggy-0.13.1 -- /Users/jaraco/code/main/pip-run/.tox/python/bin/python
cachedir: .tox/python/.pytest_cache
rootdir: /Users/jaraco/code/main/pip-run, configfile: pytest.ini
plugins: mypy-0.8.0, black-0.3.12, flake8-1.0.6, checkdocs-2.1.1, jaraco.test-3.2.0
collected 70 items / 67 deselected / 3 selected                                                                                    

pip_run/read-deps.py::FLAKE8 SKIPPED                                                                                         [ 33%]
pip_run/read-deps.py::BLACK SKIPPED                                                                                          [ 66%]
pip_run/read-deps.py::mypy PASSED                                                                                            [100%]
=============================================================== mypy ===============================================================

Success: no issues found in 1 source file
=========================================== 1 passed, 2 skipped, 67 deselected in 1.16s ============================================
_____________________________________________________________ summary ______________________________________________________________
  python: commands succeeded
  congratulations :)