Questions tagged [astroid]
10 questions
2
votes
2 answers
pylint and astroid AttributeError: 'Module' object has no attribute 'col_offset'
It fails using pylint version 2.9.0 and 2.9.3. With version 2.8.3 it still works though.
See GitHub-issue under the provided link.
Traceback (most recent call last):
File…

Andreas L.
- 3,239
- 5
- 26
- 65
2
votes
2 answers
Where does astroid change its behavior for pylint checks of relative imports?
On a Linux environment, I have the following three files in a folder named utils:
An empty file __init__.py
A file named mymain.py with the following content:
from mytool import foo
A file mytool.py with the following content:
from subprocess…

Alex
- 41,580
- 88
- 260
- 469
1
vote
2 answers
Python: How do I find all functions that return tuples explicitly?
I would like to find all functions that return an explicit tuple.
E.g.,
...
return x, y
would be in, but
...
return {"x":x, "y":y}
would be out, so regexp searching for return .*, would return too many false positives.
I suspect…

sds
- 58,617
- 29
- 161
- 278
1
vote
0 answers
Python: is it possible to infer the possible exceptions that a function can raise?
I was trying to document the possible errors that could occur as a result of a remote procedure call (RPC).
It occurred to me that it might be nice if you could do this with a little magic. Is there anything in python to infer possible exceptions…

Att Righ
- 1,439
- 1
- 16
- 29
1
vote
1 answer
RecursionError: maximum recursion depth exceeded in comparison in pylint
I have created many tests and all working fine on local and gihub CI but while check PyLint I'm getting this error RecursionError: maximum recursion depth exceeded in comparison.
I would be great if you can help me.
command running on…

Mr Singh
- 3,936
- 5
- 41
- 60
1
vote
1 answer
How to get number of conditions in if statement using Astroid?
I am working on Pylint project using Astroid package for Python.
I would like to know if there is a general and convenient way to retrieve the number of conditions branches of an if-statement using Astroid
For instance, for the statement:
if …

Or b
- 666
- 1
- 5
- 22
1
vote
0 answers
4 petal rose formula that fits astroid (pedal curve) in desmos
https://www.desmos.com/calculator/g7m5l5zaxa
\left(\frac{6\sin\left(t\right)^{2}\cos\left(t\right)}{4\sin\left(t\right)^{2}+\cos^{2}\left(t\right)},\frac{3\sin\left(t\right)\cos^{2}\left(t\right)}{4\sin\left(t\right)^{2}+\cos\left(t\right)^{2}}\right…

Ruchi Sheth
- 11
- 1
0
votes
0 answers
astroid can't infer structlog
I'm trying to write a custom pylint checker to check usage of structlog calls.
But I found, that astroid can't infer structlog calls. For example:
import astroid
snippet = """
import structlog
logger =…

eyeinthebrick
- 528
- 1
- 5
- 21
0
votes
0 answers
Infer from subclass in Pylint
I'm calling a method (assignment) which is present in the subclass, but pylint gives a no-member error as the called method is not defined in the base class.
Pylint uses infer() defined in NodeNG class (in astroid) for making these kinds of…
0
votes
1 answer
Define a `Call` node in `astroid`
I would like to define a node such as this one :
from astroid import parse
print_node = parse("print()")
print(print_node.body[0].value)
# Call(func=,
# args=[],
# keywords=None)
The only way I found to…

BlueSheepToken
- 5,751
- 3
- 17
- 42