Skip to content

MPT-17825: resolve WPS400 and WPS407 violations#163

Merged
d3rky merged 1 commit intomainfrom
codex/MPT-17825-adopt-wemake-rules-WPS400
Mar 13, 2026
Merged

MPT-17825: resolve WPS400 and WPS407 violations#163
d3rky merged 1 commit intomainfrom
codex/MPT-17825-adopt-wemake-rules-WPS400

Conversation

@svazquezco
Copy link
Contributor

@svazquezco svazquezco commented Mar 13, 2026

🤖 Codex-generated PR — Please review carefully.

Summary

  • remove obsolete ignores for WPS400, WPS402, WPS420, and WPS458
  • resolve WPS400 in package re-exports by using explicit F401 ignores with absolute imports
  • resolve WPS407 by making shared constants read-only and replacing the mutable stats template with a factory

Validation

  • make check
  • make check-all

Closes MPT-17825

Changes

  • Converted relative imports to absolute imports in package __init__.py files (accounts, price_lists, products) and added explicit __all__ declarations to define public APIs
  • Made module-level constants immutable by wrapping dictionaries with MappingProxyType in accounts/constants.py, price_lists/constants.py, and products/constants.py
  • Updated class attributes in PriceListExcelFileManager and ProductExcelFileManager to directly reference immutable constants instead of wrapping them again
  • Introduced default_results() factory function in stats.py to replace mutable DEFAULT_RESULTS and removed reliance on deepcopy() for stats initialization
  • Removed WPS458 from flake8 per-file-ignores in pyproject.toml

@svazquezco svazquezco requested a review from a team as a code owner March 13, 2026 14:14
@coderabbitai
Copy link

coderabbitai bot commented Mar 13, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 76149916-5292-409a-bd2d-141d5391fa5c

📥 Commits

Reviewing files that changed from the base of the PR and between 0220dad and f30eddf.

📒 Files selected for processing (10)
  • cli/core/accounts/__init__.py
  • cli/core/accounts/constants.py
  • cli/core/price_lists/__init__.py
  • cli/core/price_lists/constants.py
  • cli/core/price_lists/handlers/price_list_excel_file_manager.py
  • cli/core/products/__init__.py
  • cli/core/products/constants.py
  • cli/core/products/handlers/product_excel_file_manager.py
  • cli/core/stats.py
  • pyproject.toml

📝 Walkthrough

Walkthrough

This PR standardizes import patterns across package initializers by converting relative imports to absolute imports and adding explicit __all__ exports. It enhances immutability by wrapping mutable dictionary constants with MappingProxyType, updates corresponding handler classes to use these immutable constants directly, introduces a default_results() function in stats.py, and removes WPS458 from flake8 per-file ignores in pyproject.toml.

Changes

Cohort / File(s) Summary
Package Initialization Refactoring
cli/core/accounts/__init__.py, cli/core/price_lists/__init__.py, cli/core/products/__init__.py
Converted relative imports to absolute imports and added explicit __all__ exports to standardize package public APIs.
Constants Immutability
cli/core/accounts/constants.py, cli/core/price_lists/constants.py, cli/core/products/constants.py
Wrapped mutable dictionary constants (STATUS_MSG, REQUIRED_FIELDS_BY_TAB, SETTINGS_API_MAPPING, etc.) with MappingProxyType to enforce immutability at runtime.
Handler Updates
cli/core/price_lists/handlers/price_list_excel_file_manager.py, cli/core/products/handlers/product_excel_file_manager.py
Updated class attribute assignments to reference immutable constants directly instead of wrapping them with MappingProxyType, and removed redundant imports.
Stats Function
cli/core/stats.py
Added new default_results() function that returns a TabResults dictionary with initialized keys, replacing previous deepcopy(DEFAULT_RESULTS) calls throughout ProductStatsCollector and PriceListStatsCollector.
Linter Configuration
pyproject.toml
Removed WPS458 from per-file-ignores to enable flake8 WPS458 checks.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Test Coverage Required ⚠️ Warning PR modifies 10 code files in cli/core module but includes no changes to any test files in the tests/ directory. Add or update tests to cover changes made in this PR, including tests for the new default_results() function, MappingProxyType immutability, and modified import statements.
✅ Passed checks (2 passed)
Check name Status Explanation
Jira Issue Key In Title ✅ Passed The PR title contains exactly one properly formatted Jira issue key MPT-17825 at the beginning, following standard conventions.
Single Commit Required ✅ Passed The PR contains exactly one commit (f30eddf) with message 'refactor: Resolve WPS400 WPS407 baseline cleanup', confirmed by git rev-list, log queries, and file modifications.

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

📝 Coding Plan
  • Generate coding plan for human review comments

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

Tip

You can disable the changed files summary in the walkthrough.

Disable the reviews.changed_files_summary setting to disable the changed files summary in the walkthrough.

@sonarqubecloud
Copy link

@d3rky d3rky merged commit e5b9b3a into main Mar 13, 2026
4 checks passed
@d3rky d3rky deleted the codex/MPT-17825-adopt-wemake-rules-WPS400 branch March 13, 2026 15:27
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.

2 participants