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

Include current django-stubs version in reporting of config data #2338

Open
flaeppe opened this issue Aug 13, 2024 · 2 comments
Open

Include current django-stubs version in reporting of config data #2338

flaeppe opened this issue Aug 13, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@flaeppe
Copy link
Member

flaeppe commented Aug 13, 2024

I'm not 100% sure but I think that if you change version of django-stubs but keep the same version of mypy after a cached run, mypy reuses the cache and there could possibly be crashes or all sorts of, strange, errors emitted for the second run.

But if we're able to include the current django-stubs version when we report config data in

def report_config_data(self, ctx: ReportConfigContext) -> Dict[str, Any]:
# Cache would be cleared if any settings do change.
extra_data = {}
# In all places we use '_UserModel' alias as a type we want to clear cache if
# AUTH_USER_MODEL setting changes
if ctx.id.startswith("django.contrib.auth") or ctx.id in {"django.http.request", "django.test.client"}:
extra_data["AUTH_USER_MODEL"] = self.django_context.settings.AUTH_USER_MODEL
return self.plugin_config.to_json(extra_data)

We should get "automatic" cache tainting whenever switching between django-stubs versions.

I must admit that I haven't gotten around to try out if this is indeed a problem, it's just a suspicion so far. Gonna have to see if I can find 2 django-stubs versions and a snippet of code that backs up my suspicion here. Think I've recently run in to this in one of the projects I'm working on though.

What's wrong

How is that should be

System information

  • OS:
  • python version:
  • django version:
  • mypy version:
  • django-stubs version:
  • django-stubs-ext version:
@flaeppe flaeppe added the bug Something isn't working label Aug 13, 2024
@sobolevn
Copy link
Member

Yes, good idea!

@sobolevn
Copy link
Member

and django version too.

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

No branches or pull requests

2 participants