Micha Reiser
b64f2ea401
Formatter: Improve single-with item formatting for Python 3.8 or older ( #10276 )
...
## Summary
This PR changes how we format `with` statements with a single with item
for Python 3.8 or older. This change is not compatible with Black.
This is how we format a single-item with statement today
```python
def run(data_path, model_uri):
with pyspark.sql.SparkSession.builder.config(
key="spark.python.worker.reuse", value=True
).config(key="spark.ui.enabled", value=False).master(
"local-cluster[2, 1, 1024]"
).getOrCreate():
# ignore spark log output
spark.sparkContext.setLogLevel("OFF")
print(score_model(spark, data_path, model_uri))
```
This is different than how we would format the same expression if it is
inside any other clause header (`while`, `if`, ...):
```python
def run(data_path, model_uri):
while (
pyspark.sql.SparkSession.builder.config(
key="spark.python.worker.reuse", value=True
)
.config(key="spark.ui.enabled", value=False)
.master("local-cluster[2, 1, 1024]")
.getOrCreate()
):
# ignore spark log output
spark.sparkContext.setLogLevel("OFF")
print(score_model(spark, data_path, model_uri))
```
Which seems inconsistent to me.
This PR changes the formatting of the single-item with Python 3.8 or
older to match that of other clause headers.
```python
def run(data_path, model_uri):
with (
pyspark.sql.SparkSession.builder.config(
key="spark.python.worker.reuse", value=True
)
.config(key="spark.ui.enabled", value=False)
.master("local-cluster[2, 1, 1024]")
.getOrCreate()
):
# ignore spark log output
spark.sparkContext.setLogLevel("OFF")
print(score_model(spark, data_path, model_uri))
```
According to our versioning policy, this style change is gated behind a
preview flag.
## Test Plan
See added tests.
Added
2024-03-08 23:56:02 +00:00
..
2024-02-29 10:00:51 +01:00
2024-01-10 12:09:34 +00:00
2023-11-30 00:09:55 +00:00
2023-12-21 04:20:17 +00:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2024-02-29 10:00:51 +01:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2024-02-29 10:00:51 +01:00
2023-11-30 00:09:55 +00:00
2024-02-29 10:00:51 +01:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2024-02-29 10:00:51 +01:00
2024-02-29 10:00:51 +01:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2024-02-29 10:00:51 +01:00
2024-02-29 10:00:51 +01:00
2023-11-30 21:49:28 -05:00
2023-11-30 00:09:55 +00:00
2024-02-29 10:00:51 +01:00
2023-12-06 07:15:06 +00:00
2024-02-29 10:00:51 +01:00
2024-01-31 11:13:37 +01:00
2024-01-31 11:13:37 +01:00
2024-02-29 10:00:51 +01:00
2023-11-30 00:09:55 +00:00
2024-01-31 00:09:38 +05:30
2024-02-29 10:00:51 +01:00
2023-11-30 00:09:55 +00:00
2024-02-29 10:00:51 +01:00
2024-01-10 12:09:34 +00:00
2024-02-29 10:00:51 +01:00
2023-11-30 00:09:55 +00:00
2024-01-10 12:09:34 +00:00
2024-02-29 10:00:51 +01:00
2024-02-29 10:00:51 +01:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2024-01-10 12:09:34 +00:00
2024-02-29 10:00:51 +01:00
2024-02-29 10:00:51 +01:00
2024-02-29 10:00:51 +01:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2024-02-29 10:00:51 +01:00
2023-11-30 00:09:55 +00:00
2024-02-29 10:00:51 +01:00
2024-01-26 08:18:30 +01:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2023-12-13 03:43:23 +00:00
2023-11-30 21:49:28 -05:00
2024-01-04 19:39:37 -05:00
2024-02-29 10:00:51 +01:00
2023-12-19 00:43:20 -06:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2024-02-29 10:00:51 +01:00
2024-02-29 10:00:51 +01:00
2024-02-29 10:00:51 +01:00
2024-02-29 10:00:51 +01:00
2024-02-29 09:30:54 +01:00
2024-02-29 09:30:54 +01:00
2023-11-30 00:09:55 +00:00
2023-11-30 00:09:55 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2024-02-29 09:30:54 +01:00
2023-11-09 01:49:24 +00:00
2024-02-29 09:30:54 +01:00
2023-11-30 21:11:14 -05:00
2024-01-30 10:08:50 +00:00
2023-11-09 01:49:24 +00:00
2024-01-30 10:08:50 +00:00
2024-01-30 10:08:50 +00:00
2024-02-29 09:30:54 +01:00
2024-02-05 13:29:24 +00:00
2024-02-12 16:09:13 +01:00
2024-01-30 10:08:50 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-17 12:24:19 -05:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-12-14 04:58:17 +00:00
2023-11-09 01:49:24 +00:00
2024-01-30 10:08:50 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2024-02-16 20:28:11 +05:30
2024-02-16 20:28:11 +05:30
2023-11-09 01:49:24 +00:00
2023-11-30 21:11:14 -05:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2024-02-29 09:30:54 +01:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-30 21:11:14 -05:00
2023-11-09 01:49:24 +00:00
2024-02-29 09:30:54 +01:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2024-01-30 10:08:50 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2024-01-30 10:08:50 +00:00
2023-11-09 01:49:24 +00:00
2024-01-30 10:08:50 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2024-02-29 09:30:54 +01:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2024-01-04 19:39:37 -05:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2024-02-29 09:30:54 +01:00
2024-02-29 09:30:54 +01:00
2023-11-09 01:49:24 +00:00
2024-02-29 09:30:54 +01:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-30 21:49:28 -05:00
2024-02-29 09:30:54 +01:00
2024-02-29 09:30:54 +01:00
2024-01-31 11:13:37 +01:00
2024-01-31 11:13:37 +01:00
2024-01-31 11:13:37 +01:00
2024-01-31 11:13:37 +01:00
2024-01-31 11:13:37 +01:00
2024-01-31 11:13:37 +01:00
2024-01-31 11:13:37 +01:00
2024-02-02 17:56:25 +01:00
2024-01-31 11:13:37 +01:00
2024-01-31 11:13:37 +01:00
2024-01-31 11:13:37 +01:00
2024-01-31 11:13:37 +01:00
2024-01-31 11:13:37 +01:00
2024-02-02 17:56:25 +01:00
2024-01-31 11:13:37 +01:00
2024-02-02 17:56:25 +01:00
2024-01-31 11:13:37 +01:00
2024-01-31 11:13:37 +01:00
2024-01-31 11:13:37 +01:00
2024-01-31 11:13:37 +01:00
2024-01-30 10:08:50 +00:00
2024-02-29 09:30:54 +01:00
2023-11-09 01:49:24 +00:00
2024-02-29 09:30:54 +01:00
2024-01-30 10:08:50 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2024-02-29 09:30:54 +01:00
2023-11-09 01:49:24 +00:00
2023-12-03 19:15:40 -05:00
2023-11-09 01:49:24 +00:00
2024-03-08 14:45:26 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2024-02-29 09:30:54 +01:00
2024-01-08 14:47:01 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2024-02-29 09:30:54 +01:00
2023-11-09 01:49:24 +00:00
2024-02-29 09:30:54 +01:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2023-12-04 05:27:04 +00:00
2023-11-09 01:49:24 +00:00
2024-03-08 23:48:47 +00:00
2024-03-08 23:56:02 +00:00
2024-01-31 00:09:38 +05:30
2024-01-31 00:09:38 +05:30
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00
2024-02-29 09:30:54 +01:00
2023-11-09 01:49:24 +00:00
2024-01-30 10:08:50 +00:00
2023-11-09 01:49:24 +00:00
2023-11-09 01:49:24 +00:00