Skip to content

Fix PLC0415 violations#3899

Merged
arkid15r merged 4 commits intoOWASP:mainfrom
HarshitVerma109:fix-plc0415
Feb 11, 2026
Merged

Fix PLC0415 violations#3899
arkid15r merged 4 commits intoOWASP:mainfrom
HarshitVerma109:fix-plc0415

Conversation

@HarshitVerma109
Copy link
Contributor

Proposed change

Resolves #2297

Narrow PLC0415 from global ignore to per-file-ignores

Checklist

  • Required: I followed the contributing workflow
  • Required: I verified that my code works as intended and resolves the issue as described
  • Required: I ran make check-test locally: all warnings addressed, tests passed
  • I used AI for code, documentation, tests, or communication related to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 10, 2026

Summary by CodeRabbit

  • Refactor

    • Consolidated and standardized imports across application code and management commands; command output now uses Django management stdout.
  • Tests

    • Standardized import patterns in many test modules.
    • Added a couple of public exports to the API test surface.
  • Documentation

    • Added docstrings to numerous model metadata blocks for clearer inline documentation.
  • Chores

    • Updated linting configuration to use per-file ignores and align rules.

Walkthrough

Consolidated many in-function imports to module-level, added Meta/docstrings across numerous Django models, replaced direct prints with Django management command stdout writing, and narrowed PLC0415 lint ignore in pyproject.toml into targeted per-file-ignores.

Changes

Cohort / File(s) Summary
Ruff configuration
backend/pyproject.toml
Removed global PLC0415 ignore and added/adjusted per-file-ignores for specific app paths and tests.
AI utils & models
backend/apps/ai/common/utils.py, backend/apps/ai/models/*.py, backend/tests/apps/ai/...
Moved in-function imports (e.g., Chunk, model classes, BaseContextCommand) to module scope; added small Meta docstrings to AI models; tests updated to use module-level imports.
OWASP management commands & models
backend/apps/owasp/management/commands/*.py, backend/apps/owasp/models/*.py, backend/tests/apps/owasp/...
Moved timedelta and other imports to module level; replaced print with self.stdout.write in many commands; added Meta docstrings across models; tests changed to assert on command.stdout.
GitHub & related commands/models/tests
backend/apps/github/management/commands/*.py, backend/apps/github/models/*.py, backend/tests/apps/github/...
Replaced prints with self.stdout.write in commands; added Meta docstrings to many GitHub models; tests adjusted to use command stdout and consolidated datetime/imports at module level.
Slack commands, models & utils
backend/apps/slack/management/commands/slack_sync_messages.py, backend/apps/slack/models/*.py, backend/apps/slack/utils.py, backend/tests/apps/slack/...
Replaced prints with self.stdout.write in command flows; added Meta docstrings; added # noqa: PLC0415 on select local imports to satisfy new Ruff rules; tests updated accordingly.
Common & core management commands and tests
backend/apps/common/management/commands/*.py, backend/apps/core/models/prompt.py, backend/tests/apps/common/...
Switched user-facing prints to self.stdout.write; minor subprocess comment; added Meta docstring to Prompt; tests updated to mock command.stdout.
Mentorship, Nest, Member Snapshot, and other models
backend/apps/mentorship/models/..., backend/apps/nest/models/*, backend/apps/owasp/models/member_snapshot.py, ...
Added docstrings inside many nested Meta classes and a few inner enums/classes (purely documentation). Minor noqa annotation in apps.py imports.
Tests - general import consolidation & lint annotations
backend/tests/... (many modules)
Removed redundant in-test imports, moved imports to module scope, added noqa: PLC0415 where applicable, and updated tests to assert on command.stdout.write instead of patched print.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • kasya
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 71.74% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Fix PLC0415 violations' directly and clearly describes the main objective of this PR - addressing PLC0415 linting violations by narrowing the scope from global to per-file ignores.
Description check ✅ Passed The description is directly related to the changeset, explaining that the PR resolves issue #2297 by narrowing PLC0415 from global ignore to per-file-ignores in pyproject.toml.
Linked Issues check ✅ Passed The PR fully meets the acceptance criteria from issue #2297: identifies all PLC0415-triggering files, updates pyproject.toml with per-file-ignores, removes global PLC0415 ignore, and implements necessary code changes (moving imports to module-level, adding docstrings) to comply with stricter linting.
Out of Scope Changes check ✅ Passed All changes are directly related to resolving PLC0415 violations: moving imports to module-level scope, adding docstrings to Meta classes (which are necessary when enabling stricter linting), updating management commands to use Django's stdout, and updating test files accordingly.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

No actionable comments were generated in the recent review. 🎉


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

cubic-dev-ai[bot]
cubic-dev-ai bot previously approved these changes Feb 10, 2026
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 26 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

coderabbitai[bot]
coderabbitai bot previously approved these changes Feb 10, 2026
@HarshitVerma109
Copy link
Contributor Author

@arkid15r , please review it and let me know if any changes are required.

@arkid15r arkid15r enabled auto-merge February 11, 2026 03:01
@sonarqubecloud
Copy link

@codecov
Copy link

codecov bot commented Feb 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.38%. Comparing base (2fea37a) to head (c7d2148).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3899      +/-   ##
==========================================
- Coverage   95.38%   95.38%   -0.01%     
==========================================
  Files         463      463              
  Lines       14543    14540       -3     
  Branches     2061     2061              
==========================================
- Hits        13872    13869       -3     
  Misses        328      328              
  Partials      343      343              
Flag Coverage Δ
backend 95.66% <100.00%> (-0.01%) ⬇️
frontend 94.61% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
backend/apps/ai/common/utils.py 90.00% <ø> (-0.48%) ⬇️
backend/apps/ai/models/chunk.py 100.00% <ø> (ø)
backend/apps/ai/models/context.py 100.00% <ø> (ø)
backend/apps/api/models/api_key.py 89.28% <ø> (ø)
...mon/management/commands/algolia_update_replicas.py 100.00% <100.00%> (ø)
...mon/management/commands/algolia_update_synonyms.py 100.00% <100.00%> (ø)
...ckend/apps/common/management/commands/dump_data.py 91.37% <100.00%> (ø)
...kend/apps/common/management/commands/purge_data.py 100.00% <100.00%> (ø)
backend/apps/core/models/prompt.py 100.00% <ø> (ø)
...gement/commands/github_add_related_repositories.py 95.55% <100.00%> (ø)
... and 52 more

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2fea37a...c7d2148. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@arkid15r arkid15r added this pull request to the merge queue Feb 11, 2026
Merged via the queue into OWASP:main with commit 63214b6 Feb 11, 2026
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Narrow down PLC0415 global ignore to per-file-ignores in pyproject.toml

2 participants

Comments