Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 95 additions & 8 deletions backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,21 @@ line-length = 99
lint.select = [ "ALL" ]
lint.extend-select = [ "I" ]
lint.ignore = [
"ANN", # https://docs.astral.sh/ruff/rules/#flake8-annotations-ann/
"ARG002", # https://docs.astral.sh/ruff/rules/unused-method-argument/
"C901", # https://docs.astral.sh/ruff/rules/complex-structure/
"COM812", # https://docs.astral.sh/ruff/rules/missing-trailing-comma/
"D407", # https://docs.astral.sh/ruff/rules/missing-dashed-underline-after-section/
"DJ012", # https://docs.astral.sh/ruff/rules/django-unordered-body-content-in-model/
"FIX002", # https://docs.astral.sh/ruff/rules/line-contains-todo/
"PLC0415", # https://docs.astral.sh/ruff/rules/import-outside-top-level/
"ANN", # https://docs.astral.sh/ruff/rules/#flake8-annotations-ann/
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep the rest unchanged, revert the formatting changes.

"ARG002", # https://docs.astral.sh/ruff/rules/unused-method-argument/
"C901", # https://docs.astral.sh/ruff/rules/complex-structure/
"COM812", # https://docs.astral.sh/ruff/rules/missing-trailing-comma/
"D407", # https://docs.astral.sh/ruff/rules/missing-dashed-underline-after-section/
"DJ012", # https://docs.astral.sh/ruff/rules/django-unordered-body-content-in-model/
"FIX002", # https://docs.astral.sh/ruff/rules/line-contains-todo/

"PLR0912", # https://docs.astral.sh/ruff/rules/too-many-branches/
"PLR0913", # https://docs.astral.sh/ruff/rules/too-many-arguments/
"PLR0915", # https://docs.astral.sh/ruff/rules/too-many-statements/
"RUF012", # https://docs.astral.sh/ruff/rules/mutable-class-default/
"TD003", # https://docs.astral.sh/ruff/rules/missing-todo-link/
]

lint.per-file-ignores."**/__init__.py" = [
"D104", # https://docs.astral.sh/ruff/rules/undocumented-public-package/
"F401", # https://docs.astral.sh/ruff/rules/unused-import/
Expand Down Expand Up @@ -120,6 +121,92 @@ lint.per-file-ignores."**/tests/**/*.py" = [
"SLF001", # https://docs.astral.sh/ruff/rules/private-member-access/
]

# specific files that need PLC0415 ignored
lint.per-file-ignores."apps/ai/common/utils.py" = [
"PLC0415", # https://docs.astral.sh/ruff/rules/import-outside-top-level/
]
lint.per-file-ignores."apps/github/models/mixins/organization.py" = [
"PLC0415", # https://docs.astral.sh/ruff/rules/import-outside-top-level/
]
lint.per-file-ignores."apps/github/models/mixins/user.py" = [
"PLC0415", # https://docs.astral.sh/ruff/rules/import-outside-top-level/
]
lint.per-file-ignores."apps/mentorship/apps.py" = [
"PLC0415", # https://docs.astral.sh/ruff/rules/import-outside-top-level/
]
lint.per-file-ignores."apps/slack/apps.py" = [
"PLC0415", # https://docs.astral.sh/ruff/rules/import-outside-top-level/
]
lint.per-file-ignores."apps/slack/commands/events.py" = [
"PLC0415", # https://docs.astral.sh/ruff/rules/import-outside-top-level/
]
lint.per-file-ignores."apps/slack/commands/leaders.py" = [
"PLC0415", # https://docs.astral.sh/ruff/rules/import-outside-top-level/
]
lint.per-file-ignores."apps/slack/common/handlers/chapters.py" = [
"PLC0415", # https://docs.astral.sh/ruff/rules/import-outside-top-level/
]
lint.per-file-ignores."apps/slack/common/handlers/committees.py" = [
"PLC0415", # https://docs.astral.sh/ruff/rules/import-outside-top-level/
]
lint.per-file-ignores."apps/slack/common/handlers/contribute.py" = [
"PLC0415", # https://docs.astral.sh/ruff/rules/import-outside-top-level/
]
lint.per-file-ignores."apps/slack/common/handlers/projects.py" = [
"PLC0415", # https://docs.astral.sh/ruff/rules/import-outside-top-level/
]
lint.per-file-ignores."apps/slack/common/handlers/users.py" = [
"PLC0415", # https://docs.astral.sh/ruff/rules/import-outside-top-level/
]
lint.per-file-ignores."apps/slack/events/member_joined_channel/contribute.py" = [
"PLC0415", # https://docs.astral.sh/ruff/rules/import-outside-top-level/
]
lint.per-file-ignores."apps/slack/utils.py" = [
"PLC0415", # https://docs.astral.sh/ruff/rules/import-outside-top-level/
]
lint.per-file-ignores."tests/apps/ai/management/commands/ai_update_chapter_chunks_test.py" = [
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to verify that all non top-level imports are justified. The idea is to minimize them to must have cases only. This one, for example, looks like a good candidate for the removal.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arkid15r Sorry for the inefficient approach earlier.
Just to confirm—should I go ahead and move the imports to the top of the files (in cases where having them inside classes/functions isn’t justified), and then remove PLC0415 from the ignore list?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, for the cases where it's just an easy move to the top -- please do it. No all cases can be fixed though, so you will still have to keep some per file ignores, mostly for slack app.

"PLC0415", # https://docs.astral.sh/ruff/rules/import-outside-top-level/
]
lint.per-file-ignores."tests/apps/ai/management/commands/ai_update_chapter_context_test.py" = [
"PLC0415", # https://docs.astral.sh/ruff/rules/import-outside-top-level/
]
lint.per-file-ignores."tests/apps/ai/management/commands/ai_update_committee_chunks_test.py" = [
"PLC0415", # https://docs.astral.sh/ruff/rules/import-outside-top-level/
]
lint.per-file-ignores."tests/apps/ai/management/commands/ai_update_committee_context_test.py" = [
"PLC0415", # https://docs.astral.sh/ruff/rules/import-outside-top-level/
]
lint.per-file-ignores."tests/apps/ai/management/commands/ai_update_event_chunks_test.py" = [
"PLC0415", # https://docs.astral.sh/ruff/rules/import-outside-top-level/
]
lint.per-file-ignores."tests/apps/ai/management/commands/ai_update_event_context_test.py" = [
"PLC0415", # https://docs.astral.sh/ruff/rules/import-outside-top-level/
]
lint.per-file-ignores."tests/apps/ai/management/commands/ai_update_project_chunks_test.py" = [
"PLC0415", # https://docs.astral.sh/ruff/rules/import-outside-top-level/
]
lint.per-file-ignores."tests/apps/ai/management/commands/ai_update_project_context_test.py" = [
"PLC0415", # https://docs.astral.sh/ruff/rules/import-outside-top-level/
]
lint.per-file-ignores."tests/apps/ai/management/commands/ai_update_slack_message_chunks_test.py" = [
"PLC0415", # https://docs.astral.sh/ruff/rules/import-outside-top-level/
]
lint.per-file-ignores."tests/apps/ai/management/commands/ai_update_slack_message_context_test.py" = [
"PLC0415", # https://docs.astral.sh/ruff/rules/import-outside-top-level/
]
lint.per-file-ignores."tests/apps/ai/models/chunk_test.py" = [
"PLC0415", # https://docs.astral.sh/ruff/rules/import-outside-top-level/
]
lint.per-file-ignores."tests/apps/ai/models/context_test.py" = [
"PLC0415", # https://docs.astral.sh/ruff/rules/import-outside-top-level/
]
lint.per-file-ignores."tests/apps/github/management/commands/github_get_installation_id_test.py" = [
"PLC0415", # https://docs.astral.sh/ruff/rules/import-outside-top-level/
]
lint.per-file-ignores."tests/apps/slack/views_test.py" = [
"PLC0415", # https://docs.astral.sh/ruff/rules/import-outside-top-level/
]

[tool.pytest.ini_options]
DJANGO_CONFIGURATION = "Test"
DJANGO_SETTINGS_MODULE = "settings.test"
Expand Down