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
Added missing stub for 'Query.join()' #1404
Conversation
django-stubs/db/models/sql/query.pyi
Outdated
@@ -197,6 +197,7 @@ class Query(BaseExpression): | |||
def check_filterable(self, expression: Any) -> None: ... | |||
def build_lookup(self, lookups: Sequence[str], lhs: Expression | Query, rhs: Any) -> Lookup: ... | |||
def try_transform(self, lhs: Expression | Query, name: str) -> Transform: ... | |||
def join(self, join: str, reuse: str | None = ..., reuse_with_filtered_relation: bool = ...) -> str: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
join
argument is clearly not a str
: https://github.com/django/django/blob/e10c1688f96e3b2d202fe401472b7b25f6105969/django/db/models/sql/query.py#L1021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the confusion. I'll update it accordingly. Thanks for pointing it out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is described here: https://github.com/django/django/blob/e10c1688f96e3b2d202fe401472b7b25f6105969/django/db/models/sql/query.py#L995-L997
According to the description, 'join' is either a base_table_class
or join_class
. I think Type[BaseTable | Join]
would be the correct type argument in this case. Let me know your thoughts on this one. I am making a commit to test the change on the CI as pytest is giving some unexpected results at my end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you
Related issues
Fixes #1402
Code changes
Added a stub for the join method with the proper type annotations. The join method takes in a
string
for thetable
parameter and atuple
of twostrings
for the on parameter, which represents the columns from each table that should be joined. Hope it clears things up!