From 79f4abbb8db1490fc83e68c2fc5b30ea1a23955f Mon Sep 17 00:00:00 2001 From: Micha Reiser Date: Wed, 10 Jan 2024 13:37:17 +0100 Subject: [PATCH] Import Black's type aliases test (#9456) --- .../black/cases/type_aliases.options.json | 1 + .../test/fixtures/black/cases/type_aliases.py | 10 ++++++++++ .../fixtures/black/cases/type_aliases.py.expect | 15 +++++++++++++++ .../resources/test/fixtures/import_black_tests.py | 3 --- 4 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/type_aliases.options.json create mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/type_aliases.py create mode 100644 crates/ruff_python_formatter/resources/test/fixtures/black/cases/type_aliases.py.expect diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/type_aliases.options.json b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/type_aliases.options.json new file mode 100644 index 0000000000000..cf266d35406c4 --- /dev/null +++ b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/type_aliases.options.json @@ -0,0 +1 @@ +{"target_version": "py312"} \ No newline at end of file diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/type_aliases.py b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/type_aliases.py new file mode 100644 index 0000000000000..7c365c27c3868 --- /dev/null +++ b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/type_aliases.py @@ -0,0 +1,10 @@ +type A=int +type Gen[T]=list[T] +type Alias[T]=lambda: T +type And[T]=T and T +type IfElse[T]=T if T else T +type One = int; type Another = str +class X: type InClass = int + +type = aliased +print(type(42)) diff --git a/crates/ruff_python_formatter/resources/test/fixtures/black/cases/type_aliases.py.expect b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/type_aliases.py.expect new file mode 100644 index 0000000000000..8c7278beb4947 --- /dev/null +++ b/crates/ruff_python_formatter/resources/test/fixtures/black/cases/type_aliases.py.expect @@ -0,0 +1,15 @@ +type A = int +type Gen[T] = list[T] +type Alias[T] = lambda: T +type And[T] = T and T +type IfElse[T] = T if T else T +type One = int +type Another = str + + +class X: + type InClass = int + + +type = aliased +print(type(42)) diff --git a/crates/ruff_python_formatter/resources/test/fixtures/import_black_tests.py b/crates/ruff_python_formatter/resources/test/fixtures/import_black_tests.py index be1602f9ab96f..552a1fe8b255f 100755 --- a/crates/ruff_python_formatter/resources/test/fixtures/import_black_tests.py +++ b/crates/ruff_python_formatter/resources/test/fixtures/import_black_tests.py @@ -96,9 +96,6 @@ def import_fixture(fixture: Path, fixture_set: str): # Uses a different output format "decorators.py", - - # Ruff fails to parse because of a parser bug - "type_aliases.py" # #8900 #8899 ]