Comments (5)
Probably they way I currently populate __all__
is wrong. I think I need to do smth like this
globals_ = {}
exec("from {} import *".format(module_name), globals_)
all = set(globals_.keys()) - {"__builtins__"}
from pybind11-stubgen.
I think pylint might be confused here due to limited introspection in binary modules. With correct stubs for test project I have no complaints in pycharm.
At the moment pybind11-stubs
does not handle properly import of modules under different name (equivalent in python: import foo as bar
). This might be cause of some troubles for static analysis.
from pybind11-stubgen.
Closed in 1833492
from pybind11-stubgen.
Sorry for the delay @sizmailov... but that still causes the same problem. :) A better fix would have been removing just
- for m in self.submodules:
- _all_.append(m.short_name)
I think the reason pylint is complaining is that it would be expecting to find this:
__all__ = ['i', 'subpkg']
i: int
subpkg: module
And instead you're currently generating:
__all__ = ['i', 'subpkg']
i: int
I would expect instead for subpkg to not be in __all__
, and that it wouldn't be a variable? So for the above example:
__all__ = ['i']
i: int
The reason I would expect this is because pybind11-stubgen is going to create a subpkg/__init__.pyi
anyways, so the typechecker/etc will find that and use that?
from pybind11-stubgen.
__all__ = ['i', 'subpkg']
i: int = 3
This snippet is a fine piece of python code. pylint (2.6.0) does not report errors on dummy module/submodule setup similar to what you've posted earlier.
If it's ok for .py
files, should be ok for .pyi
as well. I think generated stubs are correct.
Again, I think it's lack of binary modules introspection or appreciation of stubs in pylint.
EDIT: add test module & pylint output
test module & pylint output
$ pylint pack/
************* Module pack
pack/__init__.py:1:0: C0114: Missing module docstring (missing-module-docstring)
************* Module pack.submodule
pack/submodule/__init__.py:1:0: C0114: Missing module docstring (missing-module-docstring)
------------------------------------------------------------------
Your code has been rated at 3.33/10 (previous run: 3.33/10, +0.00)
$ head pack/__init__.py pack/submodule/__init__.py
==> pack/__init__.py <==
__all__ = ["CONST_I", "submodule"]
CONST_I: int = 3
==> pack/submodule/__init__.py <==
CONST = 5
from pybind11-stubgen.
Related Issues (20)
- buffer type broken by #168 HOT 10
- submodule imports don't resolve HOT 5
- pybind11::dtype
- Option to translate pointers to `PointedType | None` HOT 1
- Failing to fully resolve classes? HOT 6
- Fully-qualified type name is not shortend in nested annotation
- Option to use TypeVars for numpy.ndarray's shape type argument HOT 2
- Using `KeysView`/`ValuesView`/`ItemsView` across sub modules can result in "can't find/import" error HOT 2
- Allow replacing `...` by `object` / `Any` / `Incomplete`? HOT 10
- Modify Enum keyword default from its __repr__ to its __str__ by default? HOT 2
- Missing wheels for newer releases HOT 2
- On using `pybind11_stubgen`-defined classes in generated stubs HOT 2
- Where to store the generated stubs? HOT 4
- KeyError: 'pop from an empty set' HOT 4
- Automatically replace invalid enum expressions with corresponding valid expression & import
- Make an interface for post-parser fixup
- Enum with custom `__str__` results in non-type-checkable stub
- Generic ItemsView, KeysView, ValuesView rendered with pybind11-master HOT 1
- Can't generate stubs for pybind11 shared object HOT 2
- Using Eigen::VectorXd results in numpy.ndarray[numpy.float64[m, 1]], Error: Can't find/import 'm' HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pybind11-stubgen.