Skip to content

Commit

Permalink
Fixed pylint and precommit for Python 3.6
Browse files Browse the repository at this point in the history
We install and run pylint only on Python >3.7 as it dropped support for
Python 3.6. This is necessary so that we can still run the remainder of
the precommit script on Python 3.6.
  • Loading branch information
mristin committed Oct 4, 2023
1 parent e7cb5e2 commit 2395fa6
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 21 deletions.
47 changes: 27 additions & 20 deletions precommit.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,22 +80,28 @@ def main() -> int:

subprocess.check_call(["mypy", "--strict"] + mypy_targets, cwd=str(repo_root))

print("Pylint'ing...")
pylint_targets = ["icontract", "tests"]
if sys.version_info < (3, 7):
print(
"Pylint dropped support for Python 3.6 and "
"you are running Python {}, so skipping.".format(sys.version_info)
)
else:
print("Pylint'ing...")
pylint_targets = ["icontract", "tests"]

if sys.version_info >= (3, 6):
pylint_targets.append("tests_3_6")
if sys.version_info >= (3, 6):
pylint_targets.append("tests_3_6")

if sys.version_info >= (3, 7):
pylint_targets.append("tests_3_7")
if sys.version_info >= (3, 7):
pylint_targets.append("tests_3_7")

if sys.version_info >= (3, 8):
pylint_targets.append("tests_3_8")
pylint_targets.append("tests_with_others")
if sys.version_info >= (3, 8):
pylint_targets.append("tests_3_8")
pylint_targets.append("tests_with_others")

subprocess.check_call(
["pylint", "--rcfile=pylint.rc"] + pylint_targets, cwd=str(repo_root)
)
subprocess.check_call(
["pylint", "--rcfile=pylint.rc"] + pylint_targets, cwd=str(repo_root)
)

print("Pydocstyle'ing...")
subprocess.check_call(["pydocstyle", "icontract"], cwd=str(repo_root))
Expand All @@ -113,14 +119,15 @@ def main() -> int:
env=env)
# yapf: enable

# yapf: disable
subprocess.check_call(
["coverage", "run",
"--source", "icontract",
"-a", "-m", "tests_3_8.async.separately_test_concurrent"],
cwd=str(repo_root),
env=env)
# yapf: enable
if sys.version_info >= (3, 8):
# yapf: disable
subprocess.check_call(
["coverage", "run",
"--source", "icontract",
"-a", "-m", "tests_3_8.async.separately_test_concurrent"],
cwd=str(repo_root),
env=env)
# yapf: enable

subprocess.check_call(["coverage", "report"])

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
],
extras_require={
"dev": [
"pylint==2.17.5",
'pylint==2.17.5;python_version>="3.7"',
"tox>=3.0.0",
"pydocstyle>=6.3.0,<7",
"coverage>=4.5.1,<5",
Expand Down

0 comments on commit 2395fa6

Please sign in to comment.