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

Provide linting for Django code / typed orm #531

Open
JCWasmx86 opened this issue Jul 26, 2024 · 2 comments
Open

Provide linting for Django code / typed orm #531

JCWasmx86 opened this issue Jul 26, 2024 · 2 comments
Labels
plugin feature specific to some third party module and therefore requires a plugin system

Comments

@JCWasmx86
Copy link

JCWasmx86 commented Jul 26, 2024

In Django you have models for representing table rows. (ORM), like e.g.

class MyModel(models.Model):
  ts = models.DateTimeField(auto_now_add=True)
  example1 = models.FloatField()
  example2 = models.ForeignKey(SomeOtherModel, on_delete=models.CASCADE)

etc. and what I would suggest is adding checking for the validity of referenced expressions (I know it's a big ask, so I would 100% understand, if you say no to it)

MyModel.objects
  .filter(exampel1__gt=5) # Error, exampel1 doesn't exist
  .order_by("tsss") # Error, tsss does not exist

obj = MyModel.objects.create(
  tss=1, # Error, tsss does not exist
  example1=1.0,
) # Error, example2 is missing

I haven't looked at the code that much, but if you estimate it's doable as "good first issue", please assign me

@DetachHead DetachHead added the plugin feature specific to some third party module and therefore requires a plugin system label Jul 27, 2024
@KotlinIsland
Copy link
Collaborator

@JCWasmx86 that's for the suggestion, typed orm would be highly based imo. i can see two routes here, unfortunately both would be a very large amount of work:

  1. address plugin system #22 and then write a plugin for this
  2. create a new concept within the type system that can be used to represent these, and similar constructs. an example of a such a concept would be typing.dataclass_transform

the simple/easy route would be to special case this exact scenario within basedpyright, which we try to limit as much as possible.
special casing has many many downsides.

@JCWasmx86
Copy link
Author

Ok, thanks for your response :( So I guess #22 is the best solution for that, but that's probably not an "First good issue" thing

@KotlinIsland KotlinIsland changed the title Provide linting for Django code Provide linting for Django code / typed orm Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin feature specific to some third party module and therefore requires a plugin system
Projects
None yet
Development

No branches or pull requests

3 participants