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

Remove Redundant User Import in djoser.urls.base #864

Open
larrysruss opened this issue Feb 14, 2025 · 0 comments
Open

Remove Redundant User Import in djoser.urls.base #864

larrysruss opened this issue Feb 14, 2025 · 0 comments

Comments

@larrysruss
Copy link

Summary

There is a redundant import in djoser.urls.base that can be safely removed.

Description

In base.py (djoser.urls.base), the User model is imported but never used:

from django.contrib.auth import get_user_model
from rest_framework.routers import DefaultRouter

from djoser import views

router = DefaultRouter()
router.register("users", views.UserViewSet)

User = get_user_model()  # This import is unused

urlpatterns = router.urls

Since User is not accessed anywhere in the file, it can be removed without affecting functionality.

Proposed Change

I removed the User import, resulting in the following simplified code:

from rest_framework.routers import DefaultRouter

from djoser import views

router = DefaultRouter()
router.register("users", views.UserViewSet)

urlpatterns = router.urls

Testing

After making this change, I ran the test suite. All tests passed except for test_constants_translations_are_up_to_date, which is unrelated to this change.

Expected Impact

This cleanup does not alter functionality but improves code clarity and eliminates unnecessary imports.
Let me know if any additional information is needed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant