Skip to content

Commit b4e05be

Browse files
authored
Merge pull request #162 from jakkdl/black_preview
Run black with --preview
2 parents 033317a + c2aefbe commit b4e05be

File tree

5 files changed

+10
-11
lines changed

5 files changed

+10
-11
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ repos:
1111
rev: 23.1.0
1212
hooks:
1313
- id: black
14+
args: [--preview]
1415

1516
- repo: https://github.com/PyCQA/autoflake
1617
rev: v2.0.1

flake8_trio/visitors/visitor103_104.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ class Visitor103_104(Flake8TrioVisitor):
3131
"TRIO104": "Cancelled (and therefore BaseException) must be re-raised.",
3232
}
3333
for poss_library in _suggestion_dict:
34-
error_codes[
35-
f"TRIO103_{'_'.join(poss_library)}"
36-
] = _trio103_common_msg + _suggestion.format(_suggestion_dict[poss_library])
34+
error_codes[f"TRIO103_{'_'.join(poss_library)}"] = (
35+
_trio103_common_msg + _suggestion.format(_suggestion_dict[poss_library])
36+
)
3737

3838
def __init__(self, *args: Any, **kwargs: Any):
3939
super().__init__(*args, **kwargs)

flake8_trio/visitors/visitor2xx.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,8 @@ def is_p_wait(arg: ast.expr) -> bool:
226226
@error_class
227227
class Visitor23X(Visitor200):
228228
error_codes = {
229-
"TRIO230": ("Sync call {0} in async function, use `{1}.open_file(...)`."),
230-
"TRIO231": ("Sync call {0} in async function, use `{1}.wrap_file({0})`."),
229+
"TRIO230": "Sync call {0} in async function, use `{1}.open_file(...)`.",
230+
"TRIO231": "Sync call {0} in async function, use `{1}.wrap_file({0})`.",
231231
}
232232

233233
def visit_Call(self, node: ast.Call):
@@ -282,7 +282,7 @@ def visit_blocking_call(self, node: ast.Call):
282282
@error_class
283283
class Visitor24X(Visitor200):
284284
error_codes = {
285-
"TRIO240": ("Avoid using os.path, prefer using {1}.Path objects."),
285+
"TRIO240": "Avoid using os.path, prefer using {1}.Path objects.",
286286
}
287287

288288
def __init__(self, *args: Any, **kwargs: Any):

flake8_trio/visitors/visitors.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ def visit_Call(self, node: ast.Call):
268268
@error_class
269269
class Visitor117(Flake8TrioVisitor):
270270
error_codes = {
271-
"TRIO117": ("Reference to {}, prefer [exceptiongroup.]BaseExceptionGroup."),
271+
"TRIO117": "Reference to {}, prefer [exceptiongroup.]BaseExceptionGroup.",
272272
}
273273

274274
# This should never actually happen given TRIO106
@@ -285,7 +285,7 @@ def visit_Attribute(self, node: ast.Attribute):
285285
@disabled_by_default
286286
class Visitor900(Flake8TrioVisitor):
287287
error_codes = {
288-
"TRIO900": ("Async generator without `@asynccontextmanager` not allowed.")
288+
"TRIO900": "Async generator without `@asynccontextmanager` not allowed."
289289
}
290290

291291
def __init__(self, *args: Any, **kwargs: Any):

tests/test_flake8_trio.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,9 +293,7 @@ def _parse_eval_file(test: str, content: str) -> tuple[list[Error], list[str]]:
293293
try:
294294
expected.append(Error(err_code, lineno, int(col), message, *args))
295295
except AttributeError as e:
296-
msg = (
297-
f"Line {lineno}: Failed to format\n {message!r}\n" f'"with\n{args}'
298-
)
296+
msg = f'Line {lineno}: Failed to format\n {message!r}\n"with\n{args}'
299297
raise ParseError(msg) from e
300298

301299
for error in expected:

0 commit comments

Comments
 (0)