PyDev code analysis understands the special __file__ and __name__ attributes but __package__ gets flagged as undefined variable. Is this a missing feature, by design, or user error?
According to the PythonCompletionWithBuiltinsPython3Test and PythonCompletionWithBuiltinsTest unit-tests inside the Pydev github repository, it seems that it supports builtin __file__, __name__, __init__, __dict__, __path__ but ignores __package__ and some other variables.
I've tested that myself using the PyDev extension in the VSCode and got a similar response:

But, there is a feature called Forced Builtins which for my VSCode PyDev plugin was set automatically as follows (also you can set it according the link I've mentioned):

However, it appears that the __package__ variable is still not recognized. Actually, it helps me in the auto-completion but after writing, it gives an Undefined variable: __package__ error.
As a workaround add __package__ to Consider the following names as globals: (comma separated) field in Eclipse Preferences / PyDev / Editor / Code Analysis / Undefined.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With