Skip to content

Commit

Permalink
Add support for python < 3.9
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcinBinkowski committed Aug 17, 2022
1 parent 836e7fa commit c467f36
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 12 deletions.
8 changes: 7 additions & 1 deletion flake8_unused_fixtures.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import ast
import sys
from typing import Any, Generator, List, Tuple, Type, Union

import pkg_resources

if sys.version_info >= (3, 9):
from ast import unparse
else:
from astunparse import unparse

MSG = "FUF100 fixture <{}> not used"


Expand Down Expand Up @@ -33,7 +39,7 @@ def _check_for_unused_fixtures(
all_fixture_names = [
arg.arg for arg in node.args.args if arg.arg not in skip_fixtures
]
body_as_str = ast.unparse(node.body)
body_as_str = unparse(node.body)
for fixture_name, fixture in zip(all_fixture_names, node.args.args):
if fixture_name not in body_as_str:
self.problems.append(
Expand Down
26 changes: 19 additions & 7 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,29 @@ version = "0.1.1"
description = "Warn about unnecesary fixtures in tests definition."
authors = ["Marcin Binkowski <binq661@gmail.com>"]
repository = "https://github.com/MarcinBinkowski/flake8_unused_fixtures"
license = "BSD-2-Clause"
readme = "README.md"
license = "BSD-3-Clause"
keywords = ["flake8", "lint"]
classifiers=[
"Intended Audience :: Developers",
"Environment :: Console",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python",
"Operating System :: OS Independent",
"License :: OSI Approved :: BSD License",
]

[tool.poetry.dependencies]
python = "^3.9"
astpretty = "^3.0.0"
python = "^3.8"
flake8 = "^5.0.4"
astunparse = "^1.6.3"

[tool.poetry.dev-dependencies]
black = "^22.6.0"
isort = "^5.10.1"
pytest = "^7.1.2"
ipdb = "^0.13.9"
astpretty = "^3.0.0"


[tool.isort]
profile = "black"
Expand Down

0 comments on commit c467f36

Please sign in to comment.