Skip to content

Run black with --preview #162

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

Merged
merged 1 commit into from
Mar 21, 2023
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
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ repos:
rev: 23.1.0
hooks:
- id: black
args: [--preview]

- repo: https://github.com/PyCQA/autoflake
rev: v2.0.1
Expand Down
6 changes: 3 additions & 3 deletions flake8_trio/visitors/visitor103_104.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ class Visitor103_104(Flake8TrioVisitor):
"TRIO104": "Cancelled (and therefore BaseException) must be re-raised.",
}
for poss_library in _suggestion_dict:
error_codes[
f"TRIO103_{'_'.join(poss_library)}"
] = _trio103_common_msg + _suggestion.format(_suggestion_dict[poss_library])
error_codes[f"TRIO103_{'_'.join(poss_library)}"] = (
_trio103_common_msg + _suggestion.format(_suggestion_dict[poss_library])
)

def __init__(self, *args: Any, **kwargs: Any):
super().__init__(*args, **kwargs)
Expand Down
6 changes: 3 additions & 3 deletions flake8_trio/visitors/visitor2xx.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ def is_p_wait(arg: ast.expr) -> bool:
@error_class
class Visitor23X(Visitor200):
error_codes = {
"TRIO230": ("Sync call {0} in async function, use `{1}.open_file(...)`."),
"TRIO231": ("Sync call {0} in async function, use `{1}.wrap_file({0})`."),
"TRIO230": "Sync call {0} in async function, use `{1}.open_file(...)`.",
"TRIO231": "Sync call {0} in async function, use `{1}.wrap_file({0})`.",
}

def visit_Call(self, node: ast.Call):
Expand Down Expand Up @@ -282,7 +282,7 @@ def visit_blocking_call(self, node: ast.Call):
@error_class
class Visitor24X(Visitor200):
error_codes = {
"TRIO240": ("Avoid using os.path, prefer using {1}.Path objects."),
"TRIO240": "Avoid using os.path, prefer using {1}.Path objects.",
}

def __init__(self, *args: Any, **kwargs: Any):
Expand Down
4 changes: 2 additions & 2 deletions flake8_trio/visitors/visitors.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def visit_Call(self, node: ast.Call):
@error_class
class Visitor117(Flake8TrioVisitor):
error_codes = {
"TRIO117": ("Reference to {}, prefer [exceptiongroup.]BaseExceptionGroup."),
"TRIO117": "Reference to {}, prefer [exceptiongroup.]BaseExceptionGroup.",
}

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

def __init__(self, *args: Any, **kwargs: Any):
Expand Down
4 changes: 1 addition & 3 deletions tests/test_flake8_trio.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,7 @@ def _parse_eval_file(test: str, content: str) -> tuple[list[Error], list[str]]:
try:
expected.append(Error(err_code, lineno, int(col), message, *args))
except AttributeError as e:
msg = (
f"Line {lineno}: Failed to format\n {message!r}\n" f'"with\n{args}'
)
msg = f'Line {lineno}: Failed to format\n {message!r}\n"with\n{args}'
raise ParseError(msg) from e

for error in expected:
Expand Down