Skip to content

Converted all relative imports to in-package absolute ones in ./django. #19707

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

lyova24
Copy link

@lyova24 lyova24 commented Aug 5, 2025

Trac ticket number

N/A

Branch description

Replaced all relative imports (e.g., from ..utils import ...) with in-package absolute imports (e.g., from django.contrib.postgres.utils import ...) across the codebase in ./django.

Use absolute imports for other Django components and relative imports for local components.
https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/coding-style/#imports

FYI: used my own pre-commit-hook shrimport

Checklist

  • This PR targets the main branch.
  • The commit message is written in past tense, mentions the ticket number, and ends with a period.
  • I have checked the "Has patch" ticket flag in the Trac system.
  • I have added or updated relevant tests.
  • I have added or updated relevant docs, including release notes if applicable.
  • I have attached screenshots in both light and dark modes for any UI changes.

@github-actions github-actions bot added the no ticket Based on PR title, no linked Trac ticket label Aug 5, 2025
@lyova24
Copy link
Author

lyova24 commented Aug 6, 2025

@sarahboyce @nessita I saw you guy reviewing other PRs.

Is there some rule that i missed and didn't follow or should i just w8 my turn?

@nessita
Copy link
Contributor

nessita commented Aug 6, 2025

@sarahboyce @nessita I saw you guy reviewing other PRs.

Is there some rule that i missed and didn't follow or should i just w8 my turn?

Hi! If you haven't already, I'd recommend reviewing the contributing guidelines and more importantly the FAQ for contributing. They explain how the review process works and what to expect in terms of timing. Specifically for this change, it's unclear if it's worth the entry in the (very curated) git history of Django.

Also, just a small note on inclusivity: phrases like "you guys" can feel gender biased. You might find heyguys.cc helpful, it offers some good alternatives.

@sarahboyce
Copy link
Contributor

Use absolute imports for other Django components and relative imports for local components.
https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/coding-style/#imports

To me the changes here are not clearly violating the above. Depending on what you define as a component, they feel to be from the same component

@lyova24
Copy link
Author

lyova24 commented Aug 6, 2025

I apologize @nessita, I didn't mean to offend you with my last comment. I'm not a native speaker, so I may not know some of the intricacies of communication in it. I'll take your remark about the phrase "you guys" into account.


Regarding the changes i made: you, @sarahboyce, are absolutely right, it all depends on what exactly we call a component. By component I mean a package. If I understand correctly, the specifics of the language indicate that the folder with the __init__.py file is a package - an assembly of combined modules.

For example, django.contrib.postgres.utils and django.contrib.postres.fields are different packages. Using a relative import of the first package from the second is not correct in my opinion, since field does not directly relate to utils and vice versa. Also, the django.contrib.postgres.fields package has it's own utils.py in it. Similarly with other examples in the PR.

I understand that the changes may seem insignificant, but nevertheless they increase the readability of the code, and its logical coherence.

I respectfully ask you to look at this PR again, excuse me for my lack of education in English and make a decision on whether this PR is useful.


With respect, lyova24. translated with translate.google.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no ticket Based on PR title, no linked Trac ticket
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants