gristlabs / asttokens

Annotate Python AST trees with source text and token information
Apache License 2.0
172 stars 34 forks source link

`asttokens` 2.0.6 has undeclared dependency on `astroid` #85

Closed domdfcoding closed 2 years ago

domdfcoding commented 2 years ago

Attempting to import asttokens when the astroid package is not installed results an a ModuleNotFoundError:

$ python3 -c "import asttokens"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/tmp/asttokens-issue/venv/lib/python3.8/site-packages/asttokens/__init__.py", line 22, in <module>
    from .asttokens import ASTTokens
  File "/tmp/asttokens-issue/venv/lib/python3.8/site-packages/asttokens/asttokens.py", line 20, in <module>
    from .util import Token, match_token, is_non_coding_token, AstNode, patched_generate_tokens
  File "/tmp/asttokens-issue/venv/lib/python3.8/site-packages/asttokens/util.py", line 26, in <module>
    from astroid.node_classes import NodeNG  # type: ignore[import]
ModuleNotFoundError: No module named 'astroid'

astroid is not listed as a dependency in setup.cfg, only six and typing, so it does not get installed when asttokens is:

https://github.com/gristlabs/asttokens/blob/beb8a4edb8df3efae028b6b28d4beebd0c89c4fa/setup.cfg#L36-L38

fcollonval commented 2 years ago

We are hit in jupyterlab too by this one: https://github.com/jupyterlab/jupyterlab/runs/7727203699?check_suite_focus=true

As this is for typing, I would make it conditional.

alexmojaki commented 2 years ago

Released 2.0.7 which should work. Sorry everyone!

alexmojaki commented 2 years ago

@cdkini @blink1073 @tlambert03 @redeboer @gambolputty @0x26res @MaxVonKnobloch

fcollonval commented 2 years ago

Thanks a lot for the quick patch @alexmojaki It fixes the error on JupyterLab.

pllim commented 2 years ago

Hello! Any plans to yank the buggy release?

alexmojaki commented 2 years ago

Thanks for the suggestion @pllim, 2.0.6 has been yanked.

pllim commented 2 years ago

Thank YOU for the quick fix!

tlambert03 commented 2 years ago

Thanks a bunch!