Skip to content

chore(checks): Init wemake-python-styleguide configuration#905

Merged
MaxymVlasov merged 18 commits intomasterfrom
add_wemake-python-styleguide
Jun 17, 2025
Merged

chore(checks): Init wemake-python-styleguide configuration#905
MaxymVlasov merged 18 commits intomasterfrom
add_wemake-python-styleguide

Conversation

@MaxymVlasov
Copy link
Copy Markdown
Collaborator

Description of your changes

  • Integrate wemake-python-styleguide and ruff
  • Add ignores for deprecated hook
  • Make initial setup of wemake-python-styleguide, by disabling a few too strict rules

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jun 6, 2025

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added wemake-python-styleguide to pre-commit hooks for enhanced code style enforcement.
    • Introduced a dedicated Flake8 configuration file for customizable linting behavior.
  • Style

    • Updated linter suppression comments throughout the codebase to address new style guide checks and clarify exceptions.
    • Improved inline documentation explaining naming conventions and linter rule exceptions.
  • Refactor

    • Changed a data structure from a mutable list to an immutable tuple for subcommand modules in the codebase.
  • Tests

    • Replaced explicit return statements with pass in test stubs for cleaner test code.

Summary by CodeRabbit

  • Chores
    • Introduced new configuration files for Flake8 and pre-commit hooks, including the wemake-python-styleguide for enhanced code style checks.
    • Updated linter and pre-commit configurations to fine-tune linting behavior and suppress specific warnings.
    • Adjusted type annotations and naming conventions to align with updated linting rules, including changes from lists to tuples and added comments to suppress naming warnings.
    • Minor test code cleanup by replacing unnecessary return statements with pass in stub methods.

Walkthrough

Linting configurations were updated by adding wemake-python-styleguide (WPS) rules to pre-commit and Ruff, introducing a Flake8 config, and applying or justifying new noqa suppressions for WPS codes in the codebase. Minor refactoring included changing a list to a tuple and renaming an exception variable for clarity.

Changes

File(s) Change Summary
.pre-commit-config.yaml Added wemake-python-styleguide pre-commit hook.
ruff.toml Configured Ruff to treat WPS rules as external for noqa preservation.
.flake8 Introduced Flake8 configuration with WPS and project-specific settings.
src/pre_commit_terraform/_cli.py Added WPS421 and WPS225 noqa comments to print and try/except blocks.
src/pre_commit_terraform/terraform_docs_replace.py Added WPS231 and WPS229 noqa comments, renamed exception variable, updated print statement noqa.
src/pre_commit_terraform/_cli_subcommands.py Changed SUBCOMMAND_MODULES from a list to a tuple.
src/pre_commit_terraform/_structs.py Added WPS115 noqa comments to IntEnum class attributes.
src/pre_commit_terraform/_types.py Added WPS115 noqa and explanatory comment to protocol class attribute.
tests/pytest/_cli_test.py Replaced explicit return None with pass in stub methods with comments.

Sequence Diagram(s)

sequenceDiagram
    participant Developer
    participant Pre-commit
    participant Ruff
    participant Flake8
    participant WPS

    Developer->>Pre-commit: Run hooks before commit
    Pre-commit->>Ruff: Lint code (with WPS as external)
    Pre-commit->>Flake8: Lint code (with WPS plugin)
    Flake8->>WPS: Apply WPS style checks
    Ruff->>Developer: Report linting results (preserve WPS-specific noqa)
    Flake8->>Developer: Report linting results (WPS and other plugins)
Loading

Suggested reviewers

  • antonbabenko
  • webknjaz
  • yermulnik

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6687da9 and 6eb082a.

📒 Files selected for processing (1)
  • src/pre_commit_terraform/terraform_docs_replace.py (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/pre_commit_terraform/terraform_docs_replace.py
✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@codecov
Copy link
Copy Markdown

codecov bot commented Jun 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.55%. Comparing base (2f8bda1) to head (ad6a5c0).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #905   +/-   ##
=======================================
  Coverage   96.55%   96.55%           
=======================================
  Files          10       10           
  Lines         261      261           
  Branches        7        7           
=======================================
  Hits          252      252           
  Misses          9        9           
Flag Coverage Δ
CI-GHA 96.55% <100.00%> (ø)
MyPy 91.47% <100.00%> (ø)
OS-Linux 96.55% <100.00%> (ø)
OS-Windows 100.00% <100.00%> (ø)
OS-macOS 100.00% <100.00%> (ø)
Py-3.10.11 100.00% <100.00%> (ø)
Py-3.10.18 100.00% <100.00%> (ø)
Py-3.11.13 100.00% <100.00%> (ø)
Py-3.11.9 100.00% <100.00%> (ø)
Py-3.12.10 100.00% <100.00%> (ø)
Py-3.12.11 100.00% <100.00%> (ø)
Py-3.13.4 96.55% <100.00%> (ø)
Py-3.13.5 100.00% <100.00%> (?)
Py-3.9.13 100.00% <100.00%> (ø)
Py-3.9.23 100.00% <100.00%> (ø)
VM-macos-13 100.00% <100.00%> (ø)
VM-macos-14 100.00% <100.00%> (ø)
VM-ubuntu-24.04 100.00% <100.00%> (ø)
VM-ubuntu-latest 91.47% <100.00%> (ø)
VM-windows-2025 100.00% <100.00%> (ø)
pytest 100.00% <100.00%> (ø)

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@MaxymVlasov MaxymVlasov force-pushed the add_wemake-python-styleguide branch from 5b6bf8a to 93cc4b8 Compare June 6, 2025 21:51
@MaxymVlasov MaxymVlasov force-pushed the add_wemake-python-styleguide branch from 62870fd to 2a1c406 Compare June 6, 2025 21:54
Comment thread setup.cfg Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
setup.cfg (1)

21-21: Correct typos in comments.

There's a typo in the per-file-ignores comment: "coplexity" should be "complexity" and "depprecated" should be "deprecated".

-  # We will not spend time on fixing coplexity in depprecated hook
+  # We will not spend time on fixing complexity in deprecated hook
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8e4d393 and 2a1c406.

📒 Files selected for processing (4)
  • ruff.toml (1 hunks)
  • setup.cfg (1 hunks)
  • src/pre_commit_terraform/_cli.py (1 hunks)
  • src/pre_commit_terraform/terraform_docs_replace.py (3 hunks)
🔇 Additional comments (6)
ruff.toml (1)

19-21: Approve treating WPS as external.

Adding external = ["WPS"] under [lint] ensures Ruff will preserve WPS-specific # noqa comments and not strip them, aligning with the PR’s goal of integrating wemake-python-styleguide suppressions.

src/pre_commit_terraform/_cli.py (2)

36-37: Approve suppression of excessive except blocks.

Applying # noqa: WPS225 to the try: block is appropriate to bypass the "too many except cases" check in this isolated context.


39-41: Approve print suppression.

Adding # noqa: T201,WPS421 to the error print statements correctly silences print-use and WPS style warnings, matching the plan to migrate to logging later.

src/pre_commit_terraform/terraform_docs_replace.py (3)

61-61: Approve WPS231 suppression on signature.

Using # noqa: WPS231 on the function signature correctly silences the complexity warning for this deprecated hook.


89-89: Approve WPS229 suppression on try block.

Suppressing # noqa: WPS229 on the try: statement is acceptable in this legacy context.


110-112: Approve inline exception suppressions.

Inline # noqa: PERF203,WPS111 on the except clause and # noqa: T201,WPS421 on the print call restore lint compliance and align with the deprecated hook’s scope.

@MaxymVlasov MaxymVlasov requested a review from webknjaz June 9, 2025 12:05
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
.pre-commit-config.yaml (1)

115-119: Group Python lint hooks for maintainability
To keep all Python linters in one place, consider moving the wemake-python-styleguide block immediately after ruff-format under the Python section. You can also add a language_version: python3 (or your supported version) to ensure the correct interpreter is used.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2a1c406 and 7d54fe4.

📒 Files selected for processing (6)
  • .flake8 (1 hunks)
  • .pre-commit-config.yaml (1 hunks)
  • src/pre_commit_terraform/_cli_subcommands.py (1 hunks)
  • src/pre_commit_terraform/_structs.py (1 hunks)
  • src/pre_commit_terraform/_types.py (1 hunks)
  • src/pre_commit_terraform/terraform_docs_replace.py (3 hunks)
✅ Files skipped from review due to trivial changes (4)
  • src/pre_commit_terraform/_structs.py
  • src/pre_commit_terraform/_types.py
  • src/pre_commit_terraform/_cli_subcommands.py
  • .flake8
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/pre_commit_terraform/terraform_docs_replace.py
⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: 🧪 Tests / pytest@🐍3.9@windows-2025
  • GitHub Check: 🧪 Tests / pytest@🐍3.13@windows-2025
  • GitHub Check: 🧪 Tests / pytest@🐍3.13@macos-13
  • GitHub Check: 🧪 Tests / pytest@🐍3.12@windows-2025
  • GitHub Check: 🧪 Tests / pytest@🐍3.12@ubuntu-24.04
  • GitHub Check: 🧪 Tests / pytest@🐍3.12@macos-14
  • GitHub Check: 🧪 Tests / pytest@🐍3.11@windows-2025
  • GitHub Check: 🧪 Tests / pytest@🐍3.10@windows-2025
  • GitHub Check: 🧪 Tests / pytest@🐍3.10@macos-13
  • GitHub Check: 🧹 Linters / pre-commit@🐍3.13@ubuntu-latest
🔇 Additional comments (1)
.pre-commit-config.yaml (1)

115-119: Pin exact revision for wemake-python-styleguide
Good job pinning the hook to a specific commit, aligning with the project’s reproducibility strategy.

Comment thread .flake8 Outdated
Comment thread .flake8 Outdated
Comment thread src/pre_commit_terraform/_types.py
Comment thread src/pre_commit_terraform/terraform_docs_replace.py
Comment thread src/pre_commit_terraform/terraform_docs_replace.py Outdated
@MaxymVlasov MaxymVlasov requested a review from webknjaz June 12, 2025 16:54
Comment thread .flake8 Outdated
Comment thread src/pre_commit_terraform/terraform_docs_replace.py Outdated
Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) <webknjaz@redhat.com>
@MaxymVlasov MaxymVlasov marked this pull request as ready for review June 13, 2025 11:20
yermulnik
yermulnik previously approved these changes Jun 13, 2025
yermulnik
yermulnik previously approved these changes Jun 16, 2025
@MaxymVlasov MaxymVlasov force-pushed the add_wemake-python-styleguide branch from c12c94b to 6eb082a Compare June 17, 2025 09:51
@MaxymVlasov MaxymVlasov requested a review from yermulnik June 17, 2025 09:52
@MaxymVlasov MaxymVlasov enabled auto-merge (squash) June 17, 2025 13:46
@MaxymVlasov MaxymVlasov disabled auto-merge June 17, 2025 13:46
@MaxymVlasov MaxymVlasov enabled auto-merge (squash) June 17, 2025 13:47
@MaxymVlasov MaxymVlasov merged commit 6c84595 into master Jun 17, 2025
40 checks passed
@MaxymVlasov MaxymVlasov deleted the add_wemake-python-styleguide branch June 17, 2025 13:49
@antonbabenko
Copy link
Copy Markdown
Owner

This PR is included in version 1.99.5 🎉

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.

4 participants