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

Dynamic settings fail as of 1.13.0 #1276

Closed
markedwards opened this issue Dec 2, 2022 · 3 comments · Fixed by #1557
Closed

Dynamic settings fail as of 1.13.0 #1276

markedwards opened this issue Dec 2, 2022 · 3 comments · Fixed by #1557
Labels
bug Something isn't working mypy-plugin Issues specific to mypy_django_plugin regression Behavior has changed for worse with a release

Comments

@markedwards
Copy link
Contributor

markedwards commented Dec 2, 2022

Bug report

What's wrong

We build Django settings dynamically, instead of using a settings.py file with static properties. This worked fine with django-stubs up until 1.13.0, but all of our settings fail with 1.13.0:

'Settings' object has no attribute 'FOO'

This seems to be caused by #1163.

How is that should be

I understand the reasoning given in #1163, but we are pinned at django-stubs 1.12.0 and would have to completely reimplement our installation in order to unblock. Can dynamically-constructed settings be supported with django-stubs, or is that door permanently closed? Maybe it could be a non-default option we could enable, accepting the potential downsides?

System information

  • OS:
  • python version: 3.10.8
  • django version: 4.1.3
  • mypy version: 0.991
  • django-stubs version: 1.13.0
  • django-stubs-ext version: 0.7.0
@markedwards markedwards added the bug Something isn't working label Dec 2, 2022
@virtualxdriver
Copy link

This notably breaks projects that make use of django-configurations.

@intgr intgr added mypy-plugin Issues specific to mypy_django_plugin regression Behavior has changed for worse with a release labels Dec 3, 2022
@BranislavBajuzik
Copy link

This also breaks projects that use django-split-settings.

@intgr
Copy link
Collaborator

intgr commented Jan 4, 2023

@sobolevn What do you think a proper solution for this issue would look like?

Being able to toggle disable the django.conf.settings integration in the mypy plugin would be one solution. Are there any alternatives that you can think of?

I know you have spoken against making the plugin more configurable. But IME the django-stubs plugin code is frequently fragile and causes mypy crashes (backlog of mypy-plugin issues). Being able to toggle off and on certain parts of the plugin would seem helpful and allow users to pick which parts they like even if other parts don't work for them. It might also help in debugging/localizing which part of plugin code is at fault.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working mypy-plugin Issues specific to mypy_django_plugin regression Behavior has changed for worse with a release
Development

Successfully merging a pull request may close this issue.

4 participants