diff --git a/docs/guide/builtins.rst b/docs/guide/builtins.rst index cd9671d1..bb0516cc 100644 --- a/docs/guide/builtins.rst +++ b/docs/guide/builtins.rst @@ -1459,10 +1459,19 @@ Built-in Rules Modify lint rule test cases from Fixit 1 to remove deprecated keyword arguments and convert the line and column values into a CodeRange. + .. important:: + The use of ``fixit.ValidTestCase`` and ``fixit.InvalidTestCase`` have been + deprecated. This rule provides upgrades only to the temporary aliases. + + Use ``fixit upgrade`` to replace the aliases with :class:`fixit.Valid` and + :class:`fixit.Invalid`. + + See the :ref:`Version 2 API Changes ` for more details. + .. attribute:: MESSAGE :no-index: - Fix deprecated Valid/Invalid keyword arguments + Fix deprecated ValidTestCase/InvalidTestCase keyword arguments .. attribute:: AUTOFIX :no-index: @@ -1487,6 +1496,7 @@ Built-in Rules .. code:: python from fixit import InvalidTestCase + InvalidTestCase( "print('hello')", line=3, @@ -1498,6 +1508,7 @@ Built-in Rules # suggested fix from fixit import InvalidTestCase + InvalidTestCase( "print('hello')", range = CodeRange(start=CodePosition(3, 10), end=CodePosition(1 + 3, 0))) diff --git a/docs/guide/quickstart.rst b/docs/guide/quickstart.rst index 694b5842..e2688194 100644 --- a/docs/guide/quickstart.rst +++ b/docs/guide/quickstart.rst @@ -143,7 +143,7 @@ Custom Rules Fixit makes it easy to write and enable new lint rules, directly in your existing codebase alongside the code they will be linting. -Lint rules in Fixit are built on top of `LibCST `_ +Lint rules in Fixit are built on top of `LibCST `_ using a :class:`~fixit.LintRule` to combine visitors and tests together in a single unit. A (very) simple rule looks like this: @@ -151,17 +151,17 @@ in a single unit. A (very) simple rule looks like this: # teambread/rules/hollywood.py - from fixit import LintRule, InvalidTestCase, ValidTestCase + from fixit import LintRule, Invalid, Valid import libcst class HollywoodNameRule(LintRule): # clean code samples VALID = [ - ValidTestCase('name = "Susan"'), + Valid('name = "Susan"'), ] # code that triggers this rule INVALID = [ - InvalidTestCase('name = "Paul"'), + Invalid('name = "Paul"'), ] def visit_SimpleString(self, node: libcst.SimpleString) -> None: diff --git a/docs/upgrade.rst b/docs/upgrade.rst index 7774f85b..6e43c01a 100644 --- a/docs/upgrade.rst +++ b/docs/upgrade.rst @@ -159,6 +159,8 @@ in a future release: All renames should be automatically upgraded with the ``fixit upgrade`` command. +.. _v2-api-changes: + Changes %%%%%%% diff --git a/src/fixit/testing.py b/src/fixit/testing.py index e14a8117..3c847ada 100644 --- a/src/fixit/testing.py +++ b/src/fixit/testing.py @@ -207,7 +207,7 @@ def add_lint_rule_tests_to_module( If argument is omitted, will default to the `LintRuleTestCase` class from fixit.common.testing. custom_test_method_name: A member method of the class passed into `test_case_type` parameter that contains the logic around asserting success or failure of - LintRule's `ValidTestCase` and `InvalidTestCase` test cases. The method will be dynamically renamed to `test__` for discovery + LintRule's `Valid` and `Invalid` test cases. The method will be dynamically renamed to `test__` for discovery by unittest. If argument is omitted, `add_lint_rule_tests_to_module` will look for a test method named `_test_method` member of `test_case_type`. fixture_dir: The directory in which fixture files for the passed rules live. Necessary only if any lint rules require fixture data for testing. diff --git a/src/fixit/upgrade/deprecated_testcase_keywords.py b/src/fixit/upgrade/deprecated_testcase_keywords.py index f38e4599..55b8de8f 100755 --- a/src/fixit/upgrade/deprecated_testcase_keywords.py +++ b/src/fixit/upgrade/deprecated_testcase_keywords.py @@ -24,9 +24,18 @@ class FixitDeprecatedTestCaseKeywords(LintRule): """ Modify lint rule test cases from Fixit 1 to remove deprecated keyword arguments and convert the line and column values into a CodeRange. + + .. important:: + The use of ``fixit.ValidTestCase`` and ``fixit.InvalidTestCase`` have been + deprecated. This rule provides upgrades only to the temporary aliases. + + Use ``fixit upgrade`` to replace the aliases with :class:`fixit.Valid` and + :class:`fixit.Invalid`. + + See the :ref:`Version 2 API Changes ` for more details. """ - MESSAGE = "Fix deprecated Valid/Invalid keyword arguments" + MESSAGE = "Fix deprecated ValidTestCase/InvalidTestCase keyword arguments" METADATA_DEPENDENCIES = (QualifiedNameProvider,) VALID = [ @@ -45,6 +54,7 @@ class FixitDeprecatedTestCaseKeywords(LintRule): Invalid( """ from fixit import InvalidTestCase + InvalidTestCase( "print('hello')", line=3, @@ -56,6 +66,7 @@ class FixitDeprecatedTestCaseKeywords(LintRule): """, expected_replacement=""" from fixit import InvalidTestCase + InvalidTestCase( "print('hello')", range = CodeRange(start=CodePosition(3, 10), end=CodePosition(1 + 3, 0)))