Skip to content

Commit

Permalink
Update formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
amyreese committed Mar 5, 2024
1 parent 911a3b6 commit 101fb2c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 16 deletions.
18 changes: 10 additions & 8 deletions src/fixit/rules/compare_primitives_by_equal.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,16 @@ def replace_operators(self, node: cst.Comparison) -> cst.Comparison:
comparator, self.PRIMITIVES
):
target = target.with_changes(
operator=cst.Equal(
whitespace_before=op.whitespace_before,
whitespace_after=op.whitespace_after,
)
if isinstance(op, cst.Is)
else cst.NotEqual(
whitespace_before=op.whitespace_before,
whitespace_after=op.whitespace_after,
operator=(
cst.Equal(
whitespace_before=op.whitespace_before,
whitespace_after=op.whitespace_after,
)
if isinstance(op, cst.Is)
else cst.NotEqual(
whitespace_before=op.whitespace_before,
whitespace_after=op.whitespace_after,
)
)
)
comparisons.append(target)
Expand Down
4 changes: 3 additions & 1 deletion src/fixit/rules/no_namedtuple.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ class NoNamedTuple(LintRule):
``@dataclass`` is faster at reading an object's nested properties and executing its methods. (`benchmark <https://medium.com/@jacktator/dataclass-vs-namedtuple-vs-object-for-performance-optimization-in-python-691e234253b9>`_)
"""

MESSAGE: str = "Instead of NamedTuple, consider using the @dataclass decorator from dataclasses instead for simplicity, efficiency and consistency."
MESSAGE: str = (
"Instead of NamedTuple, consider using the @dataclass decorator from dataclasses instead for simplicity, efficiency and consistency."
)
METADATA_DEPENDENCIES = (QualifiedNameProvider,)

VALID = [
Expand Down
8 changes: 5 additions & 3 deletions src/fixit/rules/rewrite_to_literal.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,11 @@ def visit_Call(self, node: cst.Call) -> None:
)(
cst.ensure_type(
ele.value,
cst.Tuple # type: ignore
if isinstance(ele.value, cst.Tuple)
else cst.List,
(
cst.Tuple # type: ignore
if isinstance(ele.value, cst.Tuple)
else cst.List
),
)
)
for ele in elements
Expand Down
12 changes: 8 additions & 4 deletions src/fixit/rules/sorted_attributes_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ class MyUnsortedConstants:
"""
)
]
MESSAGE: str = "It appears you are using the @sorted-attributes directive and the class variables are unsorted. See the lint autofix suggestion."
MESSAGE: str = (
"It appears you are using the @sorted-attributes directive and the class variables are unsorted. See the lint autofix suggestion."
)

def visit_ClassDef(self, node: cst.ClassDef) -> None:
doc_string = node.get_docstring()
Expand All @@ -86,9 +88,11 @@ def visit_ClassDef(self, node: cst.ClassDef) -> None:
post_assign_lines: List[LineType] = []

def _add_unmatched_line(line: LineType) -> None:
post_assign_lines.append(
line
) if found_any_assign else pre_assign_lines.append(line)
(
post_assign_lines.append(line)
if found_any_assign
else pre_assign_lines.append(line)
)

for line in node.body.body:
if m.matches(
Expand Down

0 comments on commit 101fb2c

Please sign in to comment.