Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How are you supposed to use this? #10

Closed
elianmanzueta opened this issue Jan 24, 2025 · 6 comments
Closed

How are you supposed to use this? #10

elianmanzueta opened this issue Jan 24, 2025 · 6 comments

Comments

@elianmanzueta
Copy link

elianmanzueta commented Jan 24, 2025

There was no discussion area to ask this so my apologies.

I am using basedpyright and am struggling to get this to work.

This is my pyproject.toml:

[project]
name = "python-netbox"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.13"
dependencies = [
    "pynetbox-stubs",
    "pynetbox>=7.4.1",
]

[tool.pyright]
venvPath = "."
venv = ".venv"

reportMissingTypeStubs = false

[tool.uv.sources]
pynetbox-stubs = { git = "https://github.com/interdotlink/pynetbox-stubs.git" }

And this is the output of uv pip list:

Using Python 3.13.0 environment at /home/elian/projects/python/python-netbox/.venv
Package            Version
------------------ ----------
certifi            2024.12.14
charset-normalizer 3.4.1
idna               3.10
packaging          24.2
pynetbox           7.4.1
pynetbox-stubs     0.0.3
requests           2.32.3
urllib3            2.3.0

Importing the module with import pynetbox_stubs or import pynetbox-stubs does not work, I get a ModuleNotFoundError.

I know that the module is "there", because I was able to import types using code actions, and I wasn't before, but the module that was imported was pynetbox._gen.definitions. Now all of a sudden my compiler isn't accepting that either and I can't get pyright to ignore it. Help please?

@BestuSingh
Copy link

Step 1: Make Sure Pyright Recognizes the Stubs.
Step 2: Don’t Import 'pynetbox-stubs' Directly.
Step 3: Double-Check Your Pyright Settings.
Step 4: Check if the Stubs Are Compatible.
Once everything is installed and configured, run Pyright in your project folder to ensure it’s working as expected.

@jwbensley
Copy link
Member

Sorry I don't use Pyright so I can't help. This is a problem with how you use Pyright as far as I understand (I use MVSC and MyPy for example, and everything is working as expected).

If you think there is a specific problem with pynetbox-stubs, let me know, otherwise I will close this issue.

@elianmanzueta
Copy link
Author

Hello,

Yeah I'm thinking it has to be something with Pyright. Doing pip install git+https://github.com/interdotlink/pynetbox-stubs.git#egg=pynetbox-stubs make my pynetbox module just stop working, it overwrites import pynetbox. Pyright is detecting the type stubs just fine, so I don't know what else could be the issue. You're good to close this, thank you!

@sebastian-philipp
Copy link
Contributor

it overwrites import pynetbox

Sure about this? this package only installs a pynetbox-stubs package. It should not have any impact on the pynetbox package.

@elianmanzueta
Copy link
Author

Sorry, worded it wrong. It doesn't overwrite the whole module but pyright detects pynetbox as the stub file, so all the methods are gone after import. Looks like an issue with my pyright.

@jwbensley
Copy link
Member

I am closing this issue now as agreed - but if you find a problem with this library please do open an issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants