Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"preview": "enabled"}
{"preview": "enabled", "source_type": "Stub"}
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,23 @@
}))))
}),
}


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(),
}
},
}
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -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()
),
}
},
})
)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"preview": "enabled"}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"is_update": (up := commit.hash in update_hashes)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"is_update": (up := commit.hash in update_hashes)}
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ def import_fixture(fixture: Path, fixture_set: str):
options_path = fixture_path.with_suffix(".options.json")

if len(options) > 0:
if extension == "pyi":
options["source_type"] = "Stub"

with options_path.open("w") as options_file:
json.dump(options, options_file)
elif os.path.exists(options_path):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,51 +42,39 @@ class TopLevel:
```diff
--- Black
+++ Ruff
@@ -1,7 +1,9 @@
import sys

+
@@ -3,33 +3,27 @@
class Outer:
class InnerStub: ...
+
outer_attr_after_inner_stub: int
-
class Inner:
@@ -9,27 +11,35 @@
inner_attr: int
-
outer_attr: int

+
if sys.version_info > (3, 7):
if sys.platform == "win32":
assignment = 1
+
def function_definition(self): ...
-
def f1(self) -> str: ...
+
if sys.platform != "win32":
+
def function_definition(self): ...
+
assignment = 1
-
def f2(self) -> str: ...

+
class TopLevel:
class Nested1:
foo: int
+
def bar(self): ...
-
field = 1

class Nested2:
def bar(self): ...
+
foo: int
-
field = 1
```

Expand All @@ -95,48 +83,32 @@ class TopLevel:
```python
import sys


class Outer:
class InnerStub: ...

outer_attr_after_inner_stub: int

class Inner:
inner_attr: int

outer_attr: int


if sys.version_info > (3, 7):
if sys.platform == "win32":
assignment = 1

def function_definition(self): ...

def f1(self) -> str: ...

if sys.platform != "win32":

def function_definition(self): ...

assignment = 1

def f2(self) -> str: ...


class TopLevel:
class Nested1:
foo: int

def bar(self): ...

field = 1

class Nested2:
def bar(self): ...

foo: int

field = 1
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()
),
}
},
})
)
```


Loading