Skip to content

fix: clean up dead code and naming violations (25 fixes)#1203

Open
decko wants to merge 1 commit into
pulp:mainfrom
decko:feat/ruff-dead-code-naming
Open

fix: clean up dead code and naming violations (25 fixes)#1203
decko wants to merge 1 commit into
pulp:mainfrom
decko:feat/ruff-dead-code-naming

Conversation

@decko
Copy link
Copy Markdown
Member

@decko decko commented May 12, 2026

Summary

Fix 25 ruff violations: dead code cleanup, unused arguments, and naming conventions. Net zero line change — all mechanical renames and removals.

Rule Count Fix
I001 3 Auto-fix unsorted imports
F401 5 Remove unused imports (+ 1 noqa for Django signal side-effect import)
F811 1 Auto-fix redefined-while-unused
ARG001 5 Prefix unused signal handler args with _
F841 2 Remove unused variable assignments
RUF059 3 Replace unused unpacked vars with _
B007+PERF102 1 Switch .items() to .values() when key is unused
N806 2 noqa for Django get_user_model(), lowercase test var
N802 1 Rename test_user_permissions_without_orgId to snake_case

Reduces total ruff violations from 37 → 12.

Remaining 12 violations (deferred)

All are either per-file-ignored complexity rules or scattered violations that need individual judgment:

  • Complexity: PLR0911, PLR0912, PLR0915, C901 (already per-file-ignored)
  • Small fixes: B006, B905, SIM108, SIM115, SIM117, TRY004

Test plan

  • Verify make lint shows only 12 pre-existing violations
  • Verify make format-check passes
  • Verify signal handlers still fire (renamed args only, not removed)

🤖 Generated with Claude Code

Summary by Sourcery

Clean up lint violations by removing unused variables/imports, marking intentional side-effect imports, and aligning names with project conventions across app code and tests.

Enhancements:

  • Adjust signal handler and metrics task function signatures to mark unused parameters while preserving behavior.
  • Rename test helpers and variables to follow snake_case and lowercase naming conventions for improved consistency.
  • Simplify test logic by dropping unused return values from query helpers and iteration keys where only values are asserted.

Chores:

  • Apply noqa markers for intentional side-effect imports and Django get_user_model usage to satisfy static analysis without altering runtime behavior.

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented May 12, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Mechanical Ruff cleanup across app, tasks, and tests: unused arguments/variables are marked or removed, one test function is renamed to snake_case, a few imports gain noqa annotations for intentional side effects or naming, and minor test utilities are simplified to avoid unused keys and variables.

File-Level Changes

Change Details Files
Normalize unused function arguments to satisfy Ruff ARG/RUF rules in signals and metrics helpers.
  • Prefix unused **kwargs parameters in Django signal handlers with an underscore to mark them as intentionally unused.
  • Rename unused sender parameters in signal handlers to underscored variants while keeping the call signature stable for Django.
  • Prefix unused options parameters in internal metric helper functions with an underscore to avoid unused-argument warnings while preserving the public API.
pulp_service/pulp_service/app/signals.py
pulp_service/pulp_service/app/tasks/domain_metrics.py
Remove or stop binding unused local variables in task helpers and tests.
  • Drop unused results from database cursor fetches in RDS connection test helpers while keeping the side effects of executing the queries.
  • Avoid storing queryset lookups into local variables when their values are not used, relying on the call side effects instead.
  • Ignore the third return value from a domain-and-serializer factory helper where the domain instance is unused in callers.
pulp_service/pulp_service/app/tasks/rds_connection_tests.py
pulp_service/pulp_service/tests/unit/test_create_domain_view.py
Tighten imports and document intentional side-effect or naming violations.
  • Mark the app-level signals import with a Ruff noqa so the module continues to register Django signals via side effects without appearing unused.
  • Mark the get_user_model assignment with a noqa to allow a capitalized alias that reads like a Django model class without tripping the naming rule.
  • Simplify a datetime import that pulled in an unused timezone symbol.
pulp_service/pulp_service/app/__init__.py
pulp_service/pulp_service/app/authentication.py
pulp_service/pulp_service/app/tasks/rds_connection_tests.py
Bring tests in line with Ruff naming and unused-variable rules.
  • Rename a test function to snake_case to satisfy N802 while keeping its semantics and callers intact.
  • Rename an all-caps local test variable to lowercase and update references so it no longer looks like a constant.
  • Iterate over dictionary values instead of items in a test when only the value is asserted on, removing an unused key binding.
pulp_service/pulp_service/tests/functional/test_domain_based_permissions.py
pulp_service/pulp_service/tests/functional/test_content_handler.py
pulp_service/pulp_service/tests/functional/test_task_debug.py
Prune unused model and viewset symbols as part of dead-code cleanup.
  • Drop unused imports or symbols from models and viewsets modules to satisfy F401 and related dead-code rules while preserving the public API surface.
pulp_service/pulp_service/app/models.py
pulp_service/pulp_service/app/viewsets.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-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.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@decko
Copy link
Copy Markdown
Member Author

decko commented May 12, 2026

/retest

5 similar comments
@decko
Copy link
Copy Markdown
Member Author

decko commented May 12, 2026

/retest

@decko
Copy link
Copy Markdown
Member Author

decko commented May 12, 2026

/retest

@decko
Copy link
Copy Markdown
Member Author

decko commented May 12, 2026

/retest

@decko
Copy link
Copy Markdown
Member Author

decko commented May 12, 2026

/retest

@decko
Copy link
Copy Markdown
Member Author

decko commented May 12, 2026

/retest

ARG001 (5): prefix unused signal handler args with _
F401 (1): noqa for Django side-effect import (signals)
F841 (2): remove unused variable assignments
RUF059 (3): replace unused unpacked vars with _
B007+PERF102 (1): switch .items() to .values() for unused key
N806 (2): noqa for Django get_user_model(), lowercase test var
N802 (1): rename test_user_permissions_without_orgId to snake_case
I001+F401+F811 (8): auto-fixed unsorted/unused imports

Reduces total ruff violations from 37 → 12.

Assisted-by: Claude Code <noreply@anthropic.com>
@decko decko force-pushed the feat/ruff-dead-code-naming branch from 6cb9482 to b198a4f Compare May 12, 2026 21:39
@decko
Copy link
Copy Markdown
Member Author

decko commented May 13, 2026

/retest

4 similar comments
@decko
Copy link
Copy Markdown
Member Author

decko commented May 13, 2026

/retest

@decko
Copy link
Copy Markdown
Member Author

decko commented May 13, 2026

/retest

@decko
Copy link
Copy Markdown
Member Author

decko commented May 18, 2026

/retest

@decko
Copy link
Copy Markdown
Member Author

decko commented May 19, 2026

/retest

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

Successfully merging this pull request may close these issues.

1 participant