Set source type: Stub for black tests with options (#9674)

This commit is contained in:
Micha Reiser 2024-01-29 15:54:30 +01:00 committed by GitHub
parent bea8f2ee3a
commit 0045032905
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 124 additions and 37 deletions

View file

@ -1 +1 @@
{"preview": "enabled"} {"preview": "enabled", "source_type": "Stub"}

View file

@ -34,3 +34,23 @@ my_dict = {
})))) }))))
}), }),
} }
class Random:
def func():
random_service.status.active_states.inactive = (
make_new_top_level_state_from_dict(
{
"topLevelBase": {
"secondaryBase": {
"timestamp": 1234,
"latitude": 1,
"longitude": 2,
"actionTimestamp": Timestamp(
seconds=1530584000, nanos=0
).ToJsonString(),
}
},
}
)
)

View file

@ -47,3 +47,21 @@ my_dict = {
} }
), ),
} }
class Random:
def func():
random_service.status.active_states.inactive = (
make_new_top_level_state_from_dict({
"topLevelBase": {
"secondaryBase": {
"timestamp": 1234,
"latitude": 1,
"longitude": 2,
"actionTimestamp": (
Timestamp(seconds=1530584000, nanos=0).ToJsonString()
),
}
},
})
)

View file

@ -0,0 +1 @@
{"preview": "enabled"}

View file

@ -0,0 +1,3 @@
{
"is_update": (up := commit.hash in update_hashes)
}

View file

@ -0,0 +1 @@
{"is_update": (up := commit.hash in update_hashes)}

View file

@ -68,6 +68,9 @@ def import_fixture(fixture: Path, fixture_set: str):
options_path = fixture_path.with_suffix(".options.json") options_path = fixture_path.with_suffix(".options.json")
if len(options) > 0: if len(options) > 0:
if extension == "pyi":
options["source_type"] = "Stub"
with options_path.open("w") as options_file: with options_path.open("w") as options_file:
json.dump(options, options_file) json.dump(options, options_file)
elif os.path.exists(options_path): elif os.path.exists(options_path):

View file

@ -42,51 +42,39 @@ class TopLevel:
```diff ```diff
--- Black --- Black
+++ Ruff +++ Ruff
@@ -1,7 +1,9 @@ @@ -3,33 +3,27 @@
import sys
+
class Outer: class Outer:
class InnerStub: ... class InnerStub: ...
+
outer_attr_after_inner_stub: int outer_attr_after_inner_stub: int
-
class Inner: class Inner:
@@ -9,27 +11,35 @@ inner_attr: int
-
outer_attr: int outer_attr: int
+
if sys.version_info > (3, 7): if sys.version_info > (3, 7):
if sys.platform == "win32": if sys.platform == "win32":
assignment = 1 assignment = 1
+
def function_definition(self): ... def function_definition(self): ...
-
def f1(self) -> str: ... def f1(self) -> str: ...
+
if sys.platform != "win32": if sys.platform != "win32":
+
def function_definition(self): ... def function_definition(self): ...
+
assignment = 1 assignment = 1
-
def f2(self) -> str: ... def f2(self) -> str: ...
+
class TopLevel: class TopLevel:
class Nested1: class Nested1:
foo: int foo: int
+
def bar(self): ... def bar(self): ...
-
field = 1 field = 1
class Nested2: class Nested2:
def bar(self): ... def bar(self): ...
+
foo: int foo: int
-
field = 1 field = 1
``` ```
@ -95,48 +83,32 @@ class TopLevel:
```python ```python
import sys import sys
class Outer: class Outer:
class InnerStub: ... class InnerStub: ...
outer_attr_after_inner_stub: int outer_attr_after_inner_stub: int
class Inner: class Inner:
inner_attr: int inner_attr: int
outer_attr: int outer_attr: int
if sys.version_info > (3, 7): if sys.version_info > (3, 7):
if sys.platform == "win32": if sys.platform == "win32":
assignment = 1 assignment = 1
def function_definition(self): ... def function_definition(self): ...
def f1(self) -> str: ... def f1(self) -> str: ...
if sys.platform != "win32": if sys.platform != "win32":
def function_definition(self): ... def function_definition(self): ...
assignment = 1 assignment = 1
def f2(self) -> str: ... def f2(self) -> str: ...
class TopLevel: class TopLevel:
class Nested1: class Nested1:
foo: int foo: int
def bar(self): ... def bar(self): ...
field = 1 field = 1
class Nested2: class Nested2:
def bar(self): ... def bar(self): ...
foo: int foo: int
field = 1 field = 1
``` ```

View file

@ -41,6 +41,26 @@ my_dict = {
})))) }))))
}), }),
} }
class Random:
def func():
random_service.status.active_states.inactive = (
make_new_top_level_state_from_dict(
{
"topLevelBase": {
"secondaryBase": {
"timestamp": 1234,
"latitude": 1,
"longitude": 2,
"actionTimestamp": Timestamp(
seconds=1530584000, nanos=0
).ToJsonString(),
}
},
}
)
)
``` ```
## Black Differences ## Black Differences
@ -94,6 +114,19 @@ my_dict = {
} }
{ {
@@ -58,9 +52,9 @@
"timestamp": 1234,
"latitude": 1,
"longitude": 2,
- "actionTimestamp": (
- Timestamp(seconds=1530584000, nanos=0).ToJsonString()
- ),
+ "actionTimestamp": Timestamp(
+ seconds=1530584000, nanos=0
+ ).ToJsonString(),
}
},
})
``` ```
## Ruff Output ## Ruff Output
@ -142,6 +175,24 @@ my_dict = {
} }
), ),
} }
class Random:
def func():
random_service.status.active_states.inactive = (
make_new_top_level_state_from_dict({
"topLevelBase": {
"secondaryBase": {
"timestamp": 1234,
"latitude": 1,
"longitude": 2,
"actionTimestamp": Timestamp(
seconds=1530584000, nanos=0
).ToJsonString(),
}
},
})
)
``` ```
## Black Output ## Black Output
@ -196,6 +247,24 @@ my_dict = {
} }
), ),
} }
class Random:
def func():
random_service.status.active_states.inactive = (
make_new_top_level_state_from_dict({
"topLevelBase": {
"secondaryBase": {
"timestamp": 1234,
"latitude": 1,
"longitude": 2,
"actionTimestamp": (
Timestamp(seconds=1530584000, nanos=0).ToJsonString()
),
}
},
})
)
``` ```