-
-
Notifications
You must be signed in to change notification settings - Fork 464
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
Fix suggested changes from #820 #821
Fix suggested changes from #820 #821
Conversation
1f0975c
to
572c64b
Compare
572c64b
to
a7cc58d
Compare
new_manager_info.metadata.setdefault("django", {}) | ||
new_manager_info.metadata["django"].setdefault("from_queryset_manager", {}) | ||
new_manager_info.metadata["django"]["from_queryset_manager"] = derived_queryset_fullname | ||
new_manager_info.metadata["django"] = {"from_queryset_manager": derived_queryset_fullname} |
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.
I'm guessing this slightly decreases compatibility if some other tool were to use the "django" namespace in the metadata dict?
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.
Yes, it does. Though the top-level metadata key is set as "django"
throughout django-stubs
.
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.
With a quick peek I saw that it's not always the case that "django"
is included. Mypy mentions that it's intended for a plugin to have a top-level metadata key coinciding with the plugin name:
Although, I suppose that the key should perhaps be "django-stubs"
instead
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.
Right, I'm probably bike-shedding. Seems highly unlikely that there will be conflicts. And if there are, it can be addressed in the future.
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.
True, although to perhaps minimize custom metadata usage. It could be useful with some helper to set metadata values(?). Basically just to keep the same top-level name.
def set_metadata_value(key: str, value: Any, info: TypeInfo) -> None:
info.metadata.setdefault("django-stubs", {})
info.metadata["django-stubs"][key] = value
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.
For reference, SQLAlchemy's mypy plugin has a utility getter/setter for TypeInfo
metadata: https://github.com/sqlalchemy/sqlalchemy/blob/eb716884a4abcabae84a6aaba105568e925b7d27/lib/sqlalchemy/ext/mypy/util.py#L90-L95
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!
Fixes some additional suggested changes in #820. Just minor cleanup really.
Related issues
Refs #820