Skip to content

Commit 94066c9

Browse files
authored
chore: cleanup deprecated linters (#41)
* chore: use pyupgrade for syntax check * chore: fix markdownlint * chore: fix ruff linter and formatter * chore: remove black, isort, autopep8 and flake8 * chore: update pre commit packages
1 parent 0282123 commit 94066c9

31 files changed

+352
-361
lines changed

.markdownlint.yaml

Lines changed: 0 additions & 9 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,18 @@ repos:
1313
- id: check-builtin-literals
1414
- id: check-docstring-first
1515
- id: debug-statements
16-
- id: fix-encoding-pragma
1716
- id: double-quote-string-fixer
1817
- id: check-added-large-files
1918
- id: check-merge-conflict
2019
- id: name-tests-test
2120
# ensure tests match `test_.*\.py`
22-
# NOTE: arg should be `--pytest-test-first` but only the following works now
23-
args: ['--django']
21+
args: ['--pytest-test-first']
2422
- id: no-commit-to-branch
25-
args: [--branch, master]
23+
args: [--branch, main]
24+
- repo: https://github.com/asottile/pyupgrade
25+
rev: v3.19.1
26+
hooks:
27+
- id: pyupgrade
2628
- repo: https://github.com/pre-commit/pygrep-hooks
2729
rev: v1.10.0
2830
hooks:
@@ -33,49 +35,30 @@ repos:
3335
- id: python-no-eval
3436
- id: python-no-log-warn
3537
- repo: https://github.com/igorshubovych/markdownlint-cli
36-
rev: v0.38.0
38+
rev: v0.44.0
3739
hooks:
38-
- id: markdownlint-fix
39-
args: ['--config', '.markdownlint.yaml']
40+
- id: markdownlint
41+
args: ['--config', 'pyproject.toml', '--fix']
4042
- repo: https://github.com/astral-sh/ruff-pre-commit
41-
rev: v0.1.6
43+
rev: v0.11.2
4244
hooks:
4345
- id: ruff
4446
- id: ruff-format
4547
args: ['--check']
46-
- repo: https://github.com/psf/black-pre-commit-mirror
47-
rev: 23.11.0
48-
hooks:
49-
- id: black
50-
args: ['--check']
51-
- repo: https://github.com/hhatto/autopep8
52-
rev: v2.0.4
53-
hooks:
54-
- id: autopep8
5548
- repo: https://github.com/pre-commit/mirrors-mypy
56-
rev: v1.7.0
49+
rev: v1.15.0
5750
hooks:
5851
- id: mypy
5952
additional_dependencies: ['types-pytz', 'types-requests']
60-
- repo: https://github.com/PyCQA/flake8
61-
rev: 6.1.0
62-
hooks:
63-
- id: flake8
64-
additional_dependencies: ['Flake8-pyproject==1.2.3']
6553
- repo: https://github.com/PyCQA/bandit
66-
rev: 1.7.5
54+
rev: 1.8.3
6755
hooks:
6856
- id: bandit
6957
args: ["-c", "pyproject.toml"]
7058
- repo: https://github.com/pylint-dev/pylint
71-
rev: v3.0.2
59+
rev: v3.3.6
7260
hooks:
7361
- id: pylint
74-
- repo: https://github.com/PyCQA/isort
75-
rev: 5.12.0
76-
hooks:
77-
- id: isort
78-
args: ['--check-only']
7962
- repo: https://github.com/hadialqattan/pycln
8063
rev: v2.5.0
8164
hooks:
@@ -85,7 +68,7 @@ repos:
8568
hooks:
8669
- id: checkmake
8770
- repo: https://github.com/tox-dev/pyproject-fmt
88-
rev: "1.0.0"
71+
rev: v2.5.1
8972
hooks:
9073
- id: pyproject-fmt
9174
args: ['--check']

Pipfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ httpx = "*"
99
jinja2 = "*"
1010

1111
[dev-packages]
12-
ruff = "*"
1312
mypy = "*"
1413
pytest = "*"
1514
pytest-env = "*"
@@ -19,6 +18,7 @@ setuptools = "*"
1918
build = "*"
2019
pre-commit = "*"
2120
twine = "*"
21+
ruff = "*"
2222

2323
[requires]
2424
python_version = "3.11"

Pipfile.lock

Lines changed: 268 additions & 217 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

codecov/badge.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
"""
32
This module should contain only the things relevant to the badge being computed
43
by shields.io

codecov/coverage/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
from .base import Coverage, CoverageInfo, CoverageMetadata, DiffCoverage, FileCoverage, FileDiffCoverage
32
from .pytest import PytestCoverage
43

codecov/coverage/base.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
from __future__ import annotations
32

43
import dataclasses

codecov/coverage/pytest.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
from __future__ import annotations
32

43
import datetime

codecov/diff_grouper.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
from __future__ import annotations
32

43
from collections.abc import Iterable

codecov/exceptions.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
class CoreBaseException(Exception):
32
pass
43

codecov/github.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
import dataclasses
32

43
from codecov.exceptions import (
@@ -27,7 +26,7 @@ class User:
2726

2827

2928
class Github:
30-
def __init__( # pylint: disable=too-many-arguments
29+
def __init__( # pylint: disable=too-many-arguments, too-many-positional-arguments
3130
self,
3231
client: GitHubClient,
3332
repository: str,

codecov/github_client.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
from __future__ import annotations
32

43
import httpx

codecov/groups.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
from __future__ import annotations
32

43
import base64

codecov/log.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
import logging
32

43
log = logging.getLogger('codecov')

codecov/main.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
import json
32
import os
43

codecov/settings.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
# -*- coding: utf-8 -*-
21
from __future__ import annotations
32

43
import dataclasses
54
import decimal
65
import inspect
76
import pathlib
87
from collections.abc import MutableMapping
9-
from typing import Any
8+
from typing import Any, Callable
109

1110
from codecov.exceptions import InvalidAnnotationType, MissingEnvironmentVariable
1211

@@ -116,7 +115,8 @@ def from_environ(cls, environ: MutableMapping[str, str]) -> Config:
116115
possible_variables = list(inspect.signature(cls).parameters)
117116
config_dict: dict[str, Any] = {k: v for k, v in environ.items() if k in possible_variables}
118117
for key, value in list(config_dict.items()):
119-
if func := getattr(cls, f'clean_{key.lower()}', None):
118+
if hasattr(cls, f'clean_{key.lower()}'):
119+
func: Callable = getattr(cls, f'clean_{key.lower()}')
120120
try:
121121
config_dict[key] = func(value)
122122
except ValueError as exc:
@@ -130,5 +130,5 @@ def from_environ(cls, environ: MutableMapping[str, str]) -> Config:
130130
for name, param in inspect.signature(cls).parameters.items()
131131
if param.default is inspect.Parameter.empty
132132
} - set(environ)
133-
raise MissingEnvironmentVariable(f" missing environment variable(s): {', '.join(missing)}") from e
133+
raise MissingEnvironmentVariable(f' missing environment variable(s): {", ".join(missing)}') from e
134134
return config_obj

codecov/template.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
from __future__ import annotations
32

43
import dataclasses
@@ -239,7 +238,7 @@ def get_file_url( # pylint: disable=too-many-arguments
239238
return s
240239

241240
# To link to a file in a PR, GitHub uses the link to the file overview combined with a SHA256 hash of the file path
242-
s = f"https://github.com/{repo_name}/pull/{pr_number}/files#diff-{hashlib.sha256(str(filename).encode('utf-8')).hexdigest()}"
241+
s = f'https://github.com/{repo_name}/pull/{pr_number}/files#diff-{hashlib.sha256(str(filename).encode("utf-8")).hexdigest()}'
243242

244243
if lines is not None:
245244
# R stands for Right side of the diff. But since we generate these links for new code we only need the right side.

pyproject.toml

Lines changed: 62 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
1+
[build-system]
2+
build-backend = "setuptools.build_meta"
3+
requires = [
4+
"setuptools",
5+
]
6+
17
[project]
8+
name = "python-coverage-comment"
9+
version = "2.1"
10+
description = "Create a Coverage report comment on Github PR"
11+
readme = "README.md"
12+
license = { file = "LICENSE" }
13+
maintainers = [
14+
{ name = "Pradeep Tammali", email = "[email protected]" },
15+
]
16+
requires-python = ">=3.0"
217
classifiers = [
318
"Programming Language :: Python :: 3 :: Only",
419
"Programming Language :: Python :: 3.0",
@@ -13,89 +28,39 @@ classifiers = [
1328
"Programming Language :: Python :: 3.9",
1429
"Programming Language :: Python :: 3.10",
1530
"Programming Language :: Python :: 3.11",
31+
"Programming Language :: Python :: 3.12",
32+
"Programming Language :: Python :: 3.13",
1633
]
1734
dependencies = [
1835
"httpx",
1936
"jinja2",
2037
]
21-
description = "Create a Coverage report comment on Github PR"
22-
license = {file = "LICENSE"}
23-
maintainers = [
24-
{name = "Pradeep Tammali", email = "[email protected]"},
25-
]
26-
name = "python-coverage-comment"
27-
readme = "README.md"
28-
requires-python = ">=3.0"
29-
version = "2.1"
30-
31-
[project.urls]
32-
Homepage = "https://github.com/PradeepTammali/python-coverage-comment"
33-
Issues = "https://github.com/PradeepTammali/python-coverage-comment/issues"
34-
[build-system]
35-
build-backend = "setuptools.build_meta"
36-
requires = [
37-
"setuptools",
38-
]
38+
urls.Homepage = "https://github.com/PradeepTammali/python-coverage-comment"
39+
urls.Issues = "https://github.com/PradeepTammali/python-coverage-comment/issues"
40+
scripts.codecov = "codecov.main:main"
3941

40-
[project.scripts]
41-
codecov = "codecov.main:main"
42-
[tool.autopep8]
43-
in-place = false
44-
max_line_length = 120
42+
[tool.ruff]
43+
target-version = "py311"
4544

46-
[tool.black]
4745
line-length = 120
48-
skip-string-normalization = true
49-
50-
[tool.ruff]
51-
ignore = [
52-
# format
53-
'E501', # line too long
46+
format.quote-style = "single"
47+
lint.select = [
48+
"E", # Errors
49+
"F", # Formatting
50+
"S", # Bandit
51+
"W", # Warnings
5452
]
55-
line-length = 120
56-
select = [
57-
'E', # Errors
58-
'W', # Warnings
59-
'F', # Formatting
60-
'S', # Bandit
53+
lint.ignore = [
54+
# format
55+
"E501", # line too long
6156
]
62-
target-version = 'py311'
63-
64-
[tool.ruff.mccabe]
65-
max-complexity = 10
66-
67-
[tool.ruff.lint.isort]
68-
combine-as-imports = true
69-
70-
[tool.ruff.format]
71-
quote-style = 'single'
72-
73-
[tool.ruff.per-file-ignores]
7457
# Ignore assert usage in tests
75-
'tests/*.py' = ['S101']
76-
77-
[tool.isort]
78-
combine_as_imports = true
79-
line_length = 120
80-
profile = "black"
81-
82-
[tool.flake8]
83-
ignore = ['E501', 'W503', 'W504']
84-
85-
[tool.pytest.ini_options]
86-
env = ['APP_ENVIRONMENT = unittest']
87-
88-
[tool.coverage.report]
89-
show_missing = true
90-
91-
[[tool.mypy.overrides]]
92-
check_untyped_defs = true
93-
ignore_missing_imports = true
94-
implicit_optional = true
95-
module = 'codecov.*'
58+
lint.per-file-ignores.'tests/*.py' = [ "S101" ]
59+
lint.isort.combine-as-imports = true
60+
lint.mccabe.max-complexity = 10
9661

9762
[tool.pylint.MASTER]
98-
ignore-paths = ['tests/*']
63+
ignore-paths = [ 'tests/*' ]
9964

10065
[tool.pylint.FORMAT]
10166
indent-string = ' '
@@ -111,5 +76,31 @@ disable = '''
11176
too-few-public-methods
11277
'''
11378

79+
[tool.pytest.ini_options]
80+
env = [ 'APP_ENVIRONMENT = unittest' ]
81+
82+
[tool.coverage.report]
83+
show_missing = true
84+
85+
[[tool.mypy.overrides]]
86+
check_untyped_defs = true
87+
ignore_missing_imports = true
88+
implicit_optional = true
89+
module = 'codecov.*'
90+
91+
[tool.markdownlint]
92+
default = true
93+
94+
[MD007]
95+
indent = 4
96+
97+
[MD013]
98+
# Number of characters
99+
line_length = 120
100+
# Number of characters for headings
101+
heading_line_length = 80
102+
# Number of characters for code blocks
103+
code_block_line_length = 120
104+
114105
[tool.bandit]
115-
exclude_dirs = ["tests/*"]
106+
exclude_dirs = [ "tests/*" ]

run.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
from codecov.main import Main
32

43

tests/conftest.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
# pylint: disable=redefined-outer-name
32
# mypy: disable-error-code="operator, union-attr"
43
from __future__ import annotations

0 commit comments

Comments
 (0)