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

development dependencies needed for type stubs not used when target python version doesn't match that of development environments #1866

Open
cjw296 opened this issue Feb 11, 2025 · 0 comments

Comments

@cjw296
Copy link

cjw296 commented Feb 11, 2025

I'm developing my library in a Python 3.12 virtual environment, but I would like to target Python 3.11 as a minimum, so had python the following in my pytype.toml:

python_version = '3.11'

However, my project relies on django-stubs to be installed in order to be able to be successfully type checked.

When I have python_version set to 3.12, I do not get type checking errors for django.

However, when I have python_version set to 3.11 I get errors such as the following, suggesting that django-stubs is not being used:

$ pytype --config pytype.toml 
Computing dependencies
Analyzing 26 sources with 0 local dependencies
ninja: Entering directory `.pytype'
[3/35] check testfixtures.tests.test_django.models
FAILED: /Users/chris/vcs/git/testfixtures/.pytype/pyi/testfixtures/tests/test_django/models.pyi 
/Users/chris/virtualenvs/testfixtures_312/bin/python -m pytype.main --imports_info /Users/chris/vcs/git/testfixtures/.pytype/imports/testfixtures.tests.test_django.models.imports --module-name testfixtures.tests.test_django.models --platform darwin -V 3.11 -o /Users/chris/vcs/git/testfixtures/.pytype/pyi/testfixtures/tests/test_django/models.pyi --analyze-annotated --nofail --quick /Users/chris/vcs/git/testfixtures/testfixtures/tests/test_django/models.py
/Users/chris/vcs/git/testfixtures/testfixtures/tests/test_django/models.py:1:1: error: in <module>: Can't find module 'django.db'. [import-error]

How can I have pytype check for 3.11 when it requires dependencies such as these?

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

1 participant