-
Notifications
You must be signed in to change notification settings - Fork 2
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
Remove imports for builtin django User model #2012
Conversation
ff987f5
to
011c959
Compare
011c959
to
6a35cb4
Compare
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.
worked in catching the User import. had a question about the if TYPE_CHECKING:
condition
@@ -25,6 +25,11 @@ | |||
) | |||
from main.models import TimestampedModel, TimestampedModelQuerySet | |||
|
|||
if TYPE_CHECKING: | |||
from django.contrib.auth import get_user_model | |||
|
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.
what does this code do? It doesnt seem like User is referenced anywhere in this file. Might be worth leaving a comment
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's referenced in the types of some of the function arguments: https://github.com/mitodl/mit-learn/pull/2012/files/6a35cb4f70d5a4364f2eb25905f46b76d27b788a#diff-3e244d0725c2dbf2dfd444546f36377feb3dcb0bfee9838f50a971237def1e72R336
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.
LGTM
6a35cb4
to
1357f29
Compare
What are the relevant tickets?
Part of https://github.com/mitodl/hq/issues/6679
Description (What does it do?)
django.contrib.auth.models.User
get_user_model()
orsettings.AUTH_USER_MODEL
How can this be tested?
You should be able to run the app without issue.
You can also test the lint rule by adding an import to
django.contrib.auth.models.User
in any file and runpre-commit run
and it should error.You can observe that the initial commit for this PR that added this check failed for all of the existing usages: https://results.pre-commit.ci/run/github/672068771/1738783559.KuMD_PjETSqF69WSAV5Ufg