Skip to content

refactor: switch to hooks for linting#2447

Open
Dev-iL wants to merge 2 commits intodpgaspar:masterfrom
Dev-iL:2603/hooks
Open

refactor: switch to hooks for linting#2447
Dev-iL wants to merge 2 commits intodpgaspar:masterfrom
Dev-iL:2603/hooks

Conversation

@Dev-iL
Copy link
Copy Markdown

@Dev-iL Dev-iL commented Mar 22, 2026

Description

Replace the legacy linting toolchain (black, flake8, flake8-import-order) with ruff and switch CI from running individual lint commands to prek (a Rust-based pre-commit runner) executing hooks defined in .pre-commit-config.yaml.

What changed:

  • Ruff now handles both linting (ruff check, replacing flake8 + flake8-import-order) and formatting (ruff format, replacing black). Mypy is kept as-is since ruff does not cover type checking.
  • prek replaces the ad-hoc pip install + manual invocation approach in CI with a single prek run --all-files step.
  • Added .pre-commit-config.yaml with ruff and mypy hooks.
  • Added [tool.ruff] configuration in pyproject.toml, matching the previous flake8 settings (line-length 90, same excludes, google-style import ordering via isort rules).
  • Removed [flake8] section from setup.cfg, removed [testenv:flake8] and [testenv:black] from tox.ini.
  • Updated requirements/dev.in: dropped black, flake8, flake8-import-order; added ruff and prek.
  • Auto-fixed ~62 import ordering issues and reformatted ~31 files to match ruff's formatter output.
  • Added per-file-ignores for pre-existing E721 and F811 violations to keep the migration clean.

Note regarding mypy

The 3 failing modules (validators, models.sqla, models.sqla.interface) now have ignore_errors = true with TODO comments. The old CI never actually checked them due to the broken glob, so this matches the prior behavior. The type errors can be fixed in a follow-up.

  flask_appbuilder/models/sqla/__init__.py:11: error: Variable "flask_appbuilder.models.sqla.Base" is not valid   
as a type  [valid-type]                                                                                           
  flask_appbuilder/models/sqla/__init__.py:11: note: See                                                          
https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases                                
  flask_appbuilder/models/sqla/__init__.py:11: error: Invalid base class "Base"  [misc]                           
  flask_appbuilder/validators.py:45: error: "BaseInterface" has no attribute "FilterEqual"  [attr-defined]        
  flask_appbuilder/models/sqla/interface.py:52: error: Incompatible types in assignment (expression has type      
"type[SQLAFilterConverter]", base class "BaseInterface" defined the type as "<typing special form>")              
[assignment]                                                                                                      
  flask_appbuilder/models/sqla/interface.py:584: error: "str" has no attribute "all"  [attr-defined]              
  flask_appbuilder/models/sqla/interface.py:593: error: "str" has no attribute "all"  [attr-defined]              
  flask_appbuilder/models/sqla/interface.py:602: error: "str" has no attribute "all"  [attr-defined]              
  flask_appbuilder/models/sqla/interface.py:967: error: Incompatible default for argument "list_columns" (default 
 has type "None", argument has type "list[str]")  [assignment]                                                    
  flask_appbuilder/models/sqla/interface.py:967: note: PEP 484 prohibits implicit Optional. Accordingly, mypy has 
 changed its default to no_implicit_optional=True                                                                 
  flask_appbuilder/models/sqla/interface.py:967: note: Use https://github.com/hauntsaninja/no_implicit_optional   
to automatically upgrade your codebase                                                                            
  flask_appbuilder/models/sqla/interface.py:1033: error: "SQLAInterface" has no attribute "FilterEqual"           
[attr-defined]                                                                                                    
  flask_appbuilder/models/sqla/interface.py:1035: error: "SQLAInterface" has no attribute "FilterEqual"           
[attr-defined]                                                                                                    
  Found 10 errors in 3 files (checked 90 source files) 

ADDITIONAL INFORMATION

  • Has associated issue:
  • Is CRUD MVC related.
  • Is Auth, RBAC security related.
  • Changes the security db schema.
  • Introduces new feature
  • Removes existing feature

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