feat: add MRT rule codes and # noqa suppression syntax (v1.2.0)#28
Merged
Conversation
- Auto-collect 5 built-in tests when MRTConfig is registered (no imports needed). Disable with mrt_default_tests = "false" in pytest.ini. - Add MRTFixture.assert_schema_matches() — fails on SQLAlchemy model/migration drift. Django mode delegates to manage.py makemigrations --check. - Add mrt drift CLI command for schema drift reporting. - Add MRTConfig.target_metadata field for import-path based metadata resolution. - Fix get_versions_dir() to return actual versions/ path, not script root.
Assign MRT1xx-MRT9xx codes to all 35 rules (Alembic + Django). Support standard # noqa: MRT201 suppression on migration lines, matching the ruff/flake8 convention Python developers already know. - # noqa — suppress all MRT warnings on that line - # noqa: MRT201 — suppress a specific rule - # noqa: MRT201, MRT202 — suppress multiple rules - # mrt: ignore — legacy alias, kept for backwards compatibility Rule code table: MRT101 Missing downgrade MRT201 DROP COLUMN in upgrade MRT102 No-op downgrade MRT202 DROP TABLE in upgrade MRT103 Data transform MRT203 TRUNCATE MRT104 Raw SQL w/o reverse MRT204 CASCADE DELETE MRT105 context.execute MRT205 DROP FK w/o restore MRT106 bulk_insert MRT206 DROP COLUMN in batch MRT107 RunPython (Django) MRT207 DROP VIEW w/o reverse MRT108 RunSQL (Django) MRT208 Multi-step destructive MRT209 RemoveField (Django) MRT210 DeleteModel (Django) MRT211 RunSQL DROP TABLE MRT212 RunSQL TRUNCATE MRT301 rename_table MRT302 rename_column MRT303 Column type change MRT304 ENUM value added MRT305 RenameModel (Django) MRT401 NOT NULL w/o default MRT402 NOT NULL nullable MRT403 NOT NULL raw SQL MRT404 ADD COLUMN volatile def MRT405 ADD COLUMN server_default MRT406 UNIQUE on existing data MRT407 INDEX w/o CONCURRENTLY MRT408 DROP INDEX w/o reverse MRT409 DROP CONSTRAINT w/o reverse MRT410 DROP CONSTRAINT batch MRT411 AddField NOT NULL (Django) MRT412 AlterField NOT NULL MRT413 AddIndex atomic (Django) MRT414 Missing atomic=False MRT501 SEQUENCE modification MRT502 CREATE TRIGGER MRT503 CREATE TYPE MRT901 Multiple heads MRT902 Syntax error Code column added to CLI table output and JSON output.
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
MRTxxxcodes to all 35 rules (Alembic + Django)# noqa: MRT201suppression syntax — follows the ruff/flake8 convention Python developers already know# mrt: ignorekept for backwards compatibilityRule codes
Suppression syntax
Test plan
_is_suppressed()smoke-tested for all 6 forms (bare noqa, specific code, multiple codes, mismatch, legacy, no comment)w.codepopulated correctly on real migration fixtures