Giter Club home page Giter Club logo

Comments (5)

sizmailov avatar sizmailov commented on June 15, 2024

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.

sizmailov avatar sizmailov commented on June 15, 2024

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.

sizmailov avatar sizmailov commented on June 15, 2024

Closed in 1833492

from pybind11-stubgen.

virtuald avatar virtuald commented on June 15, 2024

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.

sizmailov avatar sizmailov commented on June 15, 2024
__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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.