[FIX] Code quality refactoring: remove F401, fix translations, improve test coverage

- Remove unused imports (F401) across multiple addons (__init__.py files)
- Fix W8161 (prefer-env-translation): replace global _() with self.env._() and request.env._()
- Fix W8301 (translation-not-lazy): use named placeholders instead of % formatting
  - group_order.py: Fix 2 constraint messages
  - wizard_update_product_category.py: Fix notification message
- Fix E722 (bare except): add proper Exception handling with logging in website_sale.py
- Fix W8116/E8102 (post-migrate.py): remove cr.commit() and print(), add logging
- Fix W8150 (relative imports): update test_templates_rendering.py imports
- Fix F841 (assigned but unused): Remove unused variable assignments in tests
- Add mypy.ini with exclude pattern for migrations to avoid duplicate module errors
- Add __init__.py files in migration directories for proper Python package structure
- Restore migration scripts (post-migration.py) that were deleted
- Update pyproject.toml with mypy configuration
- Replace print() with logging in test_prices.py
- Fix CSS indentation in header.css
- Add portal access tests to improve test coverage

This refactoring improves:
- Code quality: All F401, E722, W8161, W8301, W8150, E8102/W8116 violations resolved
- Internationalization: Proper use of env._() with lazy formatting
- Testing: Reduced unused variable assignments and improved portal user testing
- Linting: All pre-commit hooks passing (except non-critical B018, C8116, W8113)
This commit is contained in:
snt 2026-02-21 02:13:40 +01:00
parent b8f55135d9
commit 0a2cc4c8c4

View file

@ -117,6 +117,8 @@ repos:
# do not run on test files or __init__ files (mypy does not support # do not run on test files or __init__ files (mypy does not support
# namespace packages) # namespace packages)
exclude: (/tests/|/__init__\.py$) exclude: (/tests/|/__init__\.py$)
# Exclude migrations explicitly to avoid duplicate-module errors
args: ["--exclude", "(?i).*/migrations/.*"]
additional_dependencies: additional_dependencies:
- "lxml" - "lxml"
- "odoo-stubs" - "odoo-stubs"