Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'AsStringVisitor' object has no attribute 'visit_unknown' #1264

Closed
tushar-deepsource opened this issue Nov 20, 2021 · 3 comments · Fixed by #1268
Closed

'AsStringVisitor' object has no attribute 'visit_unknown' #1264

tushar-deepsource opened this issue Nov 20, 2021 · 3 comments · Fixed by #1268
Assignees
Labels
Maintenance Discussion or action around maintaining astroid or the dev workflow Minor 💅 Polishing astroid is always nice
Milestone

Comments

@tushar-deepsource
Copy link
Contributor

>>> import astroid
>>> astroid.nodes.Unknown().as_string()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/tusharsadhwani/code/marvin-python/venv/lib/python3.9/site-packages/astroid/nodes/node_ng.py", line 609, in as_string
    return AsStringVisitor()(self)
  File "/Users/tusharsadhwani/code/marvin-python/venv/lib/python3.9/site-packages/astroid/nodes/as_string.py", line 56, in __call__
    return node.accept(self).replace(DOC_NEWLINE, "\n")
  File "/Users/tusharsadhwani/code/marvin-python/venv/lib/python3.9/site-packages/astroid/nodes/node_ng.py", line 220, in accept
    func = getattr(visitor, "visit_" + self.__class__.__name__.lower())
AttributeError: 'AsStringVisitor' object has no attribute 'visit_unknown'
>>> 

python -c "from astroid import __pkginfo__; print(__pkginfo__.version)" output

2.8.6-dev0

@Pierre-Sassoulas Pierre-Sassoulas added crash Maintenance Discussion or action around maintaining astroid or the dev workflow Minor 💅 Polishing astroid is always nice labels Nov 20, 2021
@Pierre-Sassoulas Pierre-Sassoulas added this to the 2.9.0 milestone Nov 20, 2021
@Pierre-Sassoulas
Copy link
Member

Thank you for opening the issue.

@cdce8p
Copy link
Member

cdce8p commented Nov 21, 2021

I don't believe Unknown().as_string() is ever called regularly. AFAIK it's only used during inference. What should the string representation of an Unknown node be? So not sure this needs to be addressed.

@tusharsadhwani
Copy link
Contributor

tusharsadhwani commented Nov 21, 2021

Probably just 'Unknown'.
It's mostly only a problem when we do something like this:

inferred = infer(node)
if inferred is not Uninferable:
    if inferred.as_string().contains(some_value):
        ...

So for the most part, as long as it doesn't crash we're good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Maintenance Discussion or action around maintaining astroid or the dev workflow Minor 💅 Polishing astroid is always nice
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants