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

AttributeError for extract_django_settings_module when combined with newest django-stubs #202

Closed
henribru opened this issue Mar 26, 2022 · 2 comments · Fixed by #203
Closed
Labels
bug Something isn't working

Comments

@henribru
Copy link
Contributor

Bug report

What's wrong

When combining djangorestframework-stubs 1.4 with the newly released django-stubs 1.10.0, Mypy will fail with:

Error constructing plugin instance of NewSemanalDRFPlugin

Traceback (most recent call last):
  File "/home/henribru/.cache/pypoetry/virtualenvs/lightkeeper-nCOOTSLY-py3.10/bin/mypy", line 8, in <module>
    sys.exit(console_entry())
  File "/home/henribru/.cache/pypoetry/virtualenvs/lightkeeper-nCOOTSLY-py3.10/lib/python3.10/site-packages/mypy/__main__.py", line 12, in console_entry
    main(None, sys.stdout, sys.stderr)
  File "mypy/main.py", line 96, in main
  File "mypy/main.py", line 173, in run_build
  File "mypy/build.py", line 180, in build
  File "mypy/build.py", line 231, in _build
  File "mypy/build.py", line 478, in load_plugins
  File "mypy/build.py", line 456, in load_plugins_from_config
  File "/home/henribru/.cache/pypoetry/virtualenvs/lightkeeper-nCOOTSLY-py3.10/lib/python3.10/site-packages/mypy_drf_plugin/main.py", line 25, in __init__
    django_settings_module = mypy_django_main.extract_django_settings_module(options.config_file)
AttributeError: module 'mypy_django_plugin.main' has no attribute 'extract_django_settings_module'

This is happening because extract_django_settings_module was removed in typeddjango/django-stubs@edec5a1

How is that should be

Ideally it should work with the newest django-stubs

System information

  • OS:
  • python version: 3.10
  • django version: 3.2.12
  • mypy version: 0.941
  • django-stubs version: 1.10.0
@sondrelg
Copy link

In case it unblocks anyone: I created a quick fix for myself here. Think configparser might only work for mypy.ini setups though.

@psasselum
Copy link

psasselum commented Oct 31, 2024

Encountered by using the new mypy 1.13, fixed by setting django-stubs to 1.9.0
When trying to use latest:

            "django-stubs[compatible-mypy]>=5.0.4",
            "djangorestframework-stubs[compatible-mypy]==3.15.1",

Error is

    The conflict is caused by:
        djangorestframework-stubs[compatible-mypy] 3.15.1 depends on mypy~=1.11.0; extra == "compatible-mypy"
        pre-commit-placeholder-package 0.0.0 depends on mypy==1.13.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging a pull request may close this issue.

3 participants