Closed q-wertz closed 1 year ago
Sorry, searched a litte bit more and it seems to be an upstream issue https://github.com/PyCQA/pylint/issues/7487.
Just wondering why
import traffic
a = traffic.core.Traffic.from_flights(flights="").clean_invalid()
gives no error…
Is there a reason why the return type differs between both functions?
Quickly looking from the phone, I would assume the from_flights
function would iterate on ""
and create an empty dataframe, which would wrap as None
and you can’t apply clean_invalid()
on None
.
That’s for the runtime.
For the typing Traffic.from_flights
should return a Traffic as stated by the type T
bound by DataFrameMixin
(therefore Traffic
not DFM)
Note that the whole code base is checked with mypy, (black, flake8 and isort). I don’t run pylint on top of it otherwise it never ends 😅
Quickly looking from the phone, I would assume the
from_flights
function would iterate on""
and create an empty dataframe, which would wrap asNone
and you can’t applyclean_invalid()
onNone
.
Was not intended for running but you are right :+1:
Note that the whole code base is checked with mypy, (black, flake8 and isort). I don’t run pylint on top of it otherwise it never ends sweat_smile
I can completely understand :sweat_smile:
I just don't get the pylint logic at that point. But maybe it gets fixed or at some point I understand enough to "fix" my code in case that is the problem…
pylint also states for objects that are of type Traffic
:
Instance of 'DataFrameMixin' has no 'icao24' memberpylint(no-member)
Instance of 'DataFrameMixin' has no 'airborne' memberpylint(no-member)
so probably just a pylint issue…
Interesting is, that mypy
states: "Traffic" has no attribute "inside_bbox" [attr-defined]mypy(error)
which I can use and is also in the documentation but I cannot find it in the code (traffic.py
, mixins.py
) :thinking:
In my experience, pylint is not as “smart-ass” as mypy...
Re: insight_bbox, it's monkey-patched in airspace.py (to avoid infinite import recursion...)
For other “lacking” methods, you can have a look at lazy.py line 468: all functions from GeographyMixin are automatically attached to the LazyTraffic mechanism :wink: I should find a way to make it look clearer to mypy (and to fellow users), but time is lacking!
Pylint reports the error
Instance of 'DataFrameMixin' has no 'clean_invalid' member
on the following code snippet:I tried to debug this but didn't get why it is interpreted as a
DataFrameMixin
…Versions