Skip to content

Commit

Permalink
Removed unnecessary matching
Browse files Browse the repository at this point in the history
  • Loading branch information
surge119 committed Jun 5, 2024
1 parent b4908da commit 1ecee30
Showing 1 changed file with 8 additions and 25 deletions.
33 changes: 8 additions & 25 deletions src/fixit/rules/deprecated_abc_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,33 +167,16 @@ def get_import_from(
Iterate over a Statement Sequence and return a Statement if it is a
`cst.ImportFrom` statement.
"""
if m.matches(
imp = m.findall(
node,
m.SimpleStatementLine(
body=[
m.ZeroOrMore(),
m.ImportFrom(
module=m.Name("collections"),
names=m.OneOf(
[m.ImportAlias(name=m.Name(n)) for n in self.imports_names]
),
),
m.ZeroOrMore(),
]
),
):
imp = m.findall(
node,
m.ImportFrom(
module=m.Name("collections"),
names=m.OneOf(
[m.ImportAlias(name=m.Name(n)) for n in self.imports_names]
),
m.ImportFrom(
module=m.Name("collections"),
names=m.OneOf(
[m.ImportAlias(name=m.Name(n)) for n in self.imports_names]
),
)[0]
return imp if isinstance(imp, cst.ImportFrom) else None

return None
),
)
return imp[0] if len(imp) > 0 and isinstance(imp[0], cst.ImportFrom) else None

def leave_Module(self, node: cst.Module) -> None:
"""
Expand Down

0 comments on commit 1ecee30

Please sign in to comment.