envoy.code.check 0.5.13__tar.gz → 0.6.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- envoy_code_check-0.6.0/PKG-INFO +113 -0
- {envoy.code.check-0.5.13 → envoy_code_check-0.6.0}/backend_shim.py +9 -2
- {envoy.code.check-0.5.13 → envoy_code_check-0.6.0}/envoy/code/check/__init__.py +0 -2
- {envoy.code.check-0.5.13 → envoy_code_check-0.6.0}/envoy/code/check/abstract/base.py +13 -12
- {envoy.code.check-0.5.13 → envoy_code_check-0.6.0}/envoy/code/check/abstract/changelog.py +14 -14
- {envoy.code.check-0.5.13 → envoy_code_check-0.6.0}/envoy/code/check/abstract/checker.py +53 -28
- {envoy.code.check-0.5.13 → envoy_code_check-0.6.0}/envoy/code/check/abstract/extensions.py +27 -28
- {envoy.code.check-0.5.13 → envoy_code_check-0.6.0}/envoy/code/check/abstract/flake8.py +16 -17
- {envoy.code.check-0.5.13 → envoy_code_check-0.6.0}/envoy/code/check/abstract/glint.py +23 -19
- {envoy.code.check-0.5.13 → envoy_code_check-0.6.0}/envoy/code/check/abstract/gofmt.py +9 -11
- {envoy.code.check-0.5.13 → envoy_code_check-0.6.0}/envoy/code/check/abstract/rst.py +9 -10
- {envoy.code.check-0.5.13 → envoy_code_check-0.6.0}/envoy/code/check/abstract/runtime_guards.py +9 -10
- {envoy.code.check-0.5.13 → envoy_code_check-0.6.0}/envoy/code/check/abstract/shellcheck.py +22 -17
- {envoy.code.check-0.5.13 → envoy_code_check-0.6.0}/envoy/code/check/abstract/yamllint.py +12 -16
- {envoy.code.check-0.5.13 → envoy_code_check-0.6.0}/envoy/code/check/abstract/yapf.py +8 -8
- {envoy.code.check-0.5.13 → envoy_code_check-0.6.0}/envoy/code/check/checker.py +15 -16
- envoy_code_check-0.6.0/envoy/code/check/exceptions.py +12 -0
- {envoy.code.check-0.5.13 → envoy_code_check-0.6.0}/envoy/code/check/interface.py +28 -28
- envoy_code_check-0.6.0/envoy/code/check/typing.py +55 -0
- envoy_code_check-0.6.0/envoy.code.check.egg-info/PKG-INFO +113 -0
- envoy_code_check-0.6.0/envoy.code.check.egg-info/requires.txt +35 -0
- envoy_code_check-0.6.0/setup.py +134 -0
- envoy.code.check-0.5.13/PKG-INFO +0 -17
- envoy.code.check-0.5.13/envoy/code/check/exceptions.py +0 -8
- envoy.code.check-0.5.13/envoy/code/check/typing.py +0 -54
- envoy.code.check-0.5.13/envoy.code.check.egg-info/PKG-INFO +0 -17
- envoy.code.check-0.5.13/envoy.code.check.egg-info/requires.txt +0 -8
- envoy.code.check-0.5.13/setup.py +0 -50
- {envoy.code.check-0.5.13 → envoy_code_check-0.6.0}/MANIFEST.in +0 -0
- {envoy.code.check-0.5.13 → envoy_code_check-0.6.0}/envoy/code/check/abstract/__init__.py +0 -0
- {envoy.code.check-0.5.13 → envoy_code_check-0.6.0}/envoy/code/check/cmd.py +0 -0
- {envoy.code.check-0.5.13 → envoy_code_check-0.6.0}/envoy/code/check/py.typed +0 -0
- {envoy.code.check-0.5.13 → envoy_code_check-0.6.0}/envoy.code.check.egg-info/SOURCES.txt +0 -0
- {envoy.code.check-0.5.13 → envoy_code_check-0.6.0}/envoy.code.check.egg-info/dependency_links.txt +0 -0
- {envoy.code.check-0.5.13 → envoy_code_check-0.6.0}/envoy.code.check.egg-info/entry_points.txt +0 -0
- {envoy.code.check-0.5.13 → envoy_code_check-0.6.0}/envoy.code.check.egg-info/namespace_packages.txt +0 -0
- {envoy.code.check-0.5.13 → envoy_code_check-0.6.0}/envoy.code.check.egg-info/top_level.txt +0 -0
- {envoy.code.check-0.5.13 → envoy_code_check-0.6.0}/setup.cfg +0 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: envoy.code.check
|
|
3
|
+
Version: 0.6.0
|
|
4
|
+
Summary: Code checker used in Envoy proxy's CI
|
|
5
|
+
Home-page: https://github.com/envoyproxy/toolshed/tree/main/py/envoy.code.check
|
|
6
|
+
Author: Ryan Northey
|
|
7
|
+
Author-email: ryan@synca.io
|
|
8
|
+
Maintainer: Ryan Northey
|
|
9
|
+
Maintainer-email: ryan@synca.io
|
|
10
|
+
License: Apache Software License 2.0
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
21
|
+
Classifier: Topic :: Software Development
|
|
22
|
+
Classifier: Typing :: Typed
|
|
23
|
+
Requires-Python: >=3.12
|
|
24
|
+
Requires-Dist: abstracts==0.2.0
|
|
25
|
+
Requires-Dist: abstracts>=0.2.0
|
|
26
|
+
Requires-Dist: aio-core==0.11.0
|
|
27
|
+
Requires-Dist: aio-run-checker==0.6.0
|
|
28
|
+
Requires-Dist: aio.core>=0.11.0
|
|
29
|
+
Requires-Dist: aio.run.checker>=0.6.0
|
|
30
|
+
Requires-Dist: envoy-base-utils==0.6.0
|
|
31
|
+
Requires-Dist: envoy.base.utils>=0.6.0
|
|
32
|
+
Requires-Dist: flake8==7.3.0
|
|
33
|
+
Requires-Dist: flake8>=6.1.0
|
|
34
|
+
Requires-Dist: packaging==26.2
|
|
35
|
+
Requires-Dist: packaging>=23.0
|
|
36
|
+
Requires-Dist: pep8-naming>=0.13.3
|
|
37
|
+
Requires-Dist: types-pyyaml==6.0.12.20260508
|
|
38
|
+
Requires-Dist: yamllint==1.38.0
|
|
39
|
+
Requires-Dist: yamllint>=1.32.0
|
|
40
|
+
Requires-Dist: yapf==0.43.0
|
|
41
|
+
Requires-Dist: yapf>=0.40.2
|
|
42
|
+
Provides-Extra: test
|
|
43
|
+
Requires-Dist: pytest>=7.4.0; extra == "test"
|
|
44
|
+
Requires-Dist: pytest-asyncio>=0.23.3; extra == "test"
|
|
45
|
+
Requires-Dist: pytest-coverage; extra == "test"
|
|
46
|
+
Requires-Dist: pytest-iters>=0.1.0; extra == "test"
|
|
47
|
+
Requires-Dist: pytest-patches>=0.1.0; extra == "test"
|
|
48
|
+
Provides-Extra: lint
|
|
49
|
+
Requires-Dist: flake8>=6.1.0; extra == "lint"
|
|
50
|
+
Provides-Extra: types
|
|
51
|
+
Requires-Dist: mypy>=1.6.0; extra == "types"
|
|
52
|
+
Requires-Dist: mypy-abstracts>=0.1.0; extra == "types"
|
|
53
|
+
Provides-Extra: publish
|
|
54
|
+
Requires-Dist: wheel>=0.41.0; extra == "publish"
|
|
55
|
+
Dynamic: author
|
|
56
|
+
Dynamic: author-email
|
|
57
|
+
Dynamic: classifier
|
|
58
|
+
Dynamic: description
|
|
59
|
+
Dynamic: home-page
|
|
60
|
+
Dynamic: license
|
|
61
|
+
Dynamic: maintainer
|
|
62
|
+
Dynamic: maintainer-email
|
|
63
|
+
Dynamic: provides-extra
|
|
64
|
+
Dynamic: requires-dist
|
|
65
|
+
Dynamic: requires-python
|
|
66
|
+
Dynamic: summary
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
envoy.code.check
|
|
70
|
+
================
|
|
71
|
+
|
|
72
|
+
Code checker used in Envoy proxy's CI.
|
|
73
|
+
|
|
74
|
+
This package provides an async checker that runs source-code checks against an
|
|
75
|
+
Envoy (or Envoy-like) checkout. Registered checks include:
|
|
76
|
+
|
|
77
|
+
- ``python_flake8`` and ``python_yapf`` for Python style
|
|
78
|
+
- ``yamllint`` for YAML files
|
|
79
|
+
- ``shellcheck`` for shell scripts
|
|
80
|
+
- ``glint`` for file hygiene checks
|
|
81
|
+
- ``gofmt`` for Go formatting
|
|
82
|
+
- ``runtime_guards`` consistency checks
|
|
83
|
+
- extension metadata, registration, owner, and fuzz-coverage checks
|
|
84
|
+
- changelog validation, including RST sanity checks
|
|
85
|
+
|
|
86
|
+
Usage
|
|
87
|
+
-----
|
|
88
|
+
|
|
89
|
+
Installed as a console script:
|
|
90
|
+
|
|
91
|
+
.. code-block:: console
|
|
92
|
+
|
|
93
|
+
$ envoy.code.check --help
|
|
94
|
+
|
|
95
|
+
Run a subset of checks against a checkout:
|
|
96
|
+
|
|
97
|
+
.. code-block:: console
|
|
98
|
+
|
|
99
|
+
$ envoy.code.check --check python_flake8 python_yapf --path /path/to/envoy
|
|
100
|
+
|
|
101
|
+
Run only against files changed since a given ref:
|
|
102
|
+
|
|
103
|
+
.. code-block:: console
|
|
104
|
+
|
|
105
|
+
$ envoy.code.check --since main --path /path/to/envoy
|
|
106
|
+
|
|
107
|
+
See ``envoy.code.check --help`` for the full set of options.
|
|
108
|
+
|
|
109
|
+
Links
|
|
110
|
+
-----
|
|
111
|
+
|
|
112
|
+
- Source: https://github.com/envoyproxy/toolshed/tree/main/py/envoy.code.check
|
|
113
|
+
- Issues: https://github.com/envoyproxy/toolshed/issues
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
|
|
2
2
|
# DO NOT EDIT THIS FILE -- AUTOGENERATED BY PANTS
|
|
3
3
|
|
|
4
|
+
import errno
|
|
4
5
|
import os
|
|
5
6
|
import setuptools.build_meta
|
|
6
7
|
|
|
7
8
|
backend = setuptools.build_meta.__legacy__
|
|
8
9
|
|
|
9
|
-
dist_dir = "dist"
|
|
10
|
+
dist_dir = "dist/"
|
|
10
11
|
build_wheel = True
|
|
11
12
|
build_sdist = True
|
|
12
13
|
wheel_config_settings = {
|
|
@@ -14,7 +15,13 @@ wheel_config_settings = {
|
|
|
14
15
|
sdist_config_settings = {
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
os.makedirs(
|
|
18
|
+
# Python 2.7 doesn't have the exist_ok arg on os.makedirs().
|
|
19
|
+
try:
|
|
20
|
+
os.makedirs(dist_dir)
|
|
21
|
+
except OSError as e:
|
|
22
|
+
if e.errno != errno.EEXIST:
|
|
23
|
+
raise
|
|
24
|
+
|
|
18
25
|
wheel_path = backend.build_wheel(dist_dir, wheel_config_settings) if build_wheel else None
|
|
19
26
|
sdist_path = backend.build_sdist(dist_dir, sdist_config_settings) if build_sdist else None
|
|
20
27
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
import asyncio
|
|
3
3
|
from concurrent import futures
|
|
4
|
-
from typing import Dict, List, Optional, Set
|
|
5
4
|
|
|
6
5
|
import abstracts
|
|
7
6
|
|
|
@@ -10,7 +9,7 @@ from aio.core.directory import ADirectory
|
|
|
10
9
|
from aio.core.functional import async_property
|
|
11
10
|
|
|
12
11
|
from envoy.base import utils
|
|
13
|
-
from envoy.code.check import interface
|
|
12
|
+
from envoy.code.check import interface, typing
|
|
14
13
|
|
|
15
14
|
|
|
16
15
|
@abstracts.implementer(event.IExecutive)
|
|
@@ -20,18 +19,20 @@ class ACodeCheck(event.AExecutive, metaclass=abstracts.Abstraction):
|
|
|
20
19
|
self,
|
|
21
20
|
directory: ADirectory,
|
|
22
21
|
fix: bool = False,
|
|
23
|
-
binaries:
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
binaries: dict[str, str] | None = None,
|
|
23
|
+
config: typing.YAMLConfigDict | None = None,
|
|
24
|
+
loop: asyncio.AbstractEventLoop | None = None,
|
|
25
|
+
pool: futures.Executor | None = None) -> None:
|
|
26
26
|
self.directory = directory
|
|
27
|
+
self.config = config
|
|
27
28
|
self._fix = fix
|
|
28
29
|
self._loop = loop
|
|
29
30
|
self._pool = pool
|
|
30
31
|
self._binaries = binaries
|
|
31
32
|
|
|
32
33
|
@property
|
|
33
|
-
def binaries(self):
|
|
34
|
-
return self._binaries
|
|
34
|
+
def binaries(self) -> dict[str, str]:
|
|
35
|
+
return self._binaries or {}
|
|
35
36
|
|
|
36
37
|
|
|
37
38
|
@abstracts.implementer(interface.IFileCodeCheck)
|
|
@@ -39,11 +40,11 @@ class AFileCodeCheck(ACodeCheck, metaclass=abstracts.Abstraction):
|
|
|
39
40
|
|
|
40
41
|
@async_property
|
|
41
42
|
@abstracts.interfacemethod
|
|
42
|
-
async def checker_files(self) ->
|
|
43
|
+
async def checker_files(self) -> set[str]:
|
|
43
44
|
raise NotImplementedError
|
|
44
45
|
|
|
45
46
|
@async_property(cache=True)
|
|
46
|
-
async def files(self) ->
|
|
47
|
+
async def files(self) -> set[str]:
|
|
47
48
|
files = await self.directory.files
|
|
48
49
|
return (
|
|
49
50
|
files & await self.checker_files
|
|
@@ -56,13 +57,13 @@ class AFileCodeCheck(ACodeCheck, metaclass=abstracts.Abstraction):
|
|
|
56
57
|
|
|
57
58
|
@async_property
|
|
58
59
|
@abstracts.interfacemethod
|
|
59
|
-
async def problem_files(self) ->
|
|
60
|
-
"""Discovered files with
|
|
60
|
+
async def problem_files(self) -> dict[str, list[str]]:
|
|
61
|
+
"""Discovered files with errors."""
|
|
61
62
|
raise NotImplementedError
|
|
62
63
|
|
|
63
64
|
|
|
64
65
|
@abstracts.implementer(interface.IProjectCodeCheck)
|
|
65
|
-
class AProjectCodeCheck(ACodeCheck,
|
|
66
|
+
class AProjectCodeCheck(ACodeCheck, metaclass=abstracts.Abstraction):
|
|
66
67
|
|
|
67
68
|
def __init__(
|
|
68
69
|
self,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import itertools
|
|
3
3
|
from datetime import datetime
|
|
4
4
|
from functools import cached_property
|
|
5
|
-
from
|
|
5
|
+
from collections.abc import Iterator
|
|
6
6
|
|
|
7
7
|
from packaging import version as _version
|
|
8
8
|
|
|
@@ -30,7 +30,7 @@ class AChangelogChangesChecker(metaclass=abstracts.Abstraction):
|
|
|
30
30
|
|
|
31
31
|
@property # type:ignore
|
|
32
32
|
@abstracts.interfacemethod
|
|
33
|
-
def change_checkers(self) ->
|
|
33
|
+
def change_checkers(self) -> tuple[interface.IRSTCheck, ...]:
|
|
34
34
|
raise NotImplementedError
|
|
35
35
|
|
|
36
36
|
@cached_property
|
|
@@ -41,7 +41,7 @@ class AChangelogChangesChecker(metaclass=abstracts.Abstraction):
|
|
|
41
41
|
self,
|
|
42
42
|
version: _version.Version,
|
|
43
43
|
section: str,
|
|
44
|
-
entry: utils.typing.ChangeDict) ->
|
|
44
|
+
entry: utils.typing.ChangeDict) -> tuple[str, ...]:
|
|
45
45
|
change = entry["change"].strip()
|
|
46
46
|
errors = [
|
|
47
47
|
checker(change)
|
|
@@ -61,7 +61,7 @@ class AChangelogChangesChecker(metaclass=abstracts.Abstraction):
|
|
|
61
61
|
self,
|
|
62
62
|
version: _version.Version,
|
|
63
63
|
section: str,
|
|
64
|
-
data:
|
|
64
|
+
data: utils.typing.ChangeList | None) -> tuple[str, ...]:
|
|
65
65
|
name_error = self.check_section_name(version, section)
|
|
66
66
|
return (
|
|
67
67
|
*((name_error, )
|
|
@@ -76,7 +76,7 @@ class AChangelogChangesChecker(metaclass=abstracts.Abstraction):
|
|
|
76
76
|
self,
|
|
77
77
|
version: _version.Version,
|
|
78
78
|
sections: utils.typing.ChangelogChangeSectionsDict) -> (
|
|
79
|
-
|
|
79
|
+
tuple[str, ...]):
|
|
80
80
|
return tuple(
|
|
81
81
|
itertools.chain.from_iterable(
|
|
82
82
|
self.check_section(version, section, data) # type:ignore
|
|
@@ -86,7 +86,7 @@ class AChangelogChangesChecker(metaclass=abstracts.Abstraction):
|
|
|
86
86
|
def check_section_name(
|
|
87
87
|
self,
|
|
88
88
|
version: _version.Version,
|
|
89
|
-
section: str) ->
|
|
89
|
+
section: str) -> str | None:
|
|
90
90
|
invalid_changes = (
|
|
91
91
|
section == "changes"
|
|
92
92
|
and version > self.max_version_for_changes_section)
|
|
@@ -137,7 +137,7 @@ class AChangelogStatus(metaclass=abstracts.Abstraction):
|
|
|
137
137
|
self.version).exists())
|
|
138
138
|
|
|
139
139
|
@async_property(cache=True)
|
|
140
|
-
async def errors(self) ->
|
|
140
|
+
async def errors(self) -> tuple[str, ...]:
|
|
141
141
|
try:
|
|
142
142
|
return (
|
|
143
143
|
*self.check_version(),
|
|
@@ -147,7 +147,7 @@ class AChangelogStatus(metaclass=abstracts.Abstraction):
|
|
|
147
147
|
return (f"{self.version}: {e}", )
|
|
148
148
|
|
|
149
149
|
@async_property
|
|
150
|
-
async def invalid_date(self) ->
|
|
150
|
+
async def invalid_date(self) -> str | None:
|
|
151
151
|
if await self.is_pending:
|
|
152
152
|
return None
|
|
153
153
|
date = await self.date
|
|
@@ -194,7 +194,7 @@ class AChangelogStatus(metaclass=abstracts.Abstraction):
|
|
|
194
194
|
self.version
|
|
195
195
|
> _version.Version(self.project.version.base_version))
|
|
196
196
|
|
|
197
|
-
async def check_date(self) ->
|
|
197
|
+
async def check_date(self) -> tuple[str, ...]:
|
|
198
198
|
errors = []
|
|
199
199
|
if invalid_date := await self.invalid_date:
|
|
200
200
|
errors.append(f"Format not recognized \"{invalid_date}\"")
|
|
@@ -207,7 +207,7 @@ class AChangelogStatus(metaclass=abstracts.Abstraction):
|
|
|
207
207
|
for e
|
|
208
208
|
in errors)
|
|
209
209
|
|
|
210
|
-
async def check_sections(self) ->
|
|
210
|
+
async def check_sections(self) -> tuple[str, ...]:
|
|
211
211
|
# Runs checker in executor, uncomment following line for debugging
|
|
212
212
|
# return self.checker.check_sections(self.version, await self.sections)
|
|
213
213
|
return await self.project.execute(
|
|
@@ -215,7 +215,7 @@ class AChangelogStatus(metaclass=abstracts.Abstraction):
|
|
|
215
215
|
self.version,
|
|
216
216
|
await self.sections)
|
|
217
217
|
|
|
218
|
-
def check_version(self) ->
|
|
218
|
+
def check_version(self) -> tuple[str, ...]:
|
|
219
219
|
errors = []
|
|
220
220
|
if self.duplicate_current:
|
|
221
221
|
errors.append(
|
|
@@ -245,7 +245,7 @@ class AChangelogCheck(
|
|
|
245
245
|
@property # type:ignore
|
|
246
246
|
@abstracts.interfacemethod
|
|
247
247
|
def changes_checker_class(
|
|
248
|
-
self) ->
|
|
248
|
+
self) -> type[interface.IChangelogChangesChecker]:
|
|
249
249
|
raise NotImplementedError
|
|
250
250
|
|
|
251
251
|
@cached_property
|
|
@@ -255,11 +255,11 @@ class AChangelogCheck(
|
|
|
255
255
|
|
|
256
256
|
@property # type:ignore
|
|
257
257
|
@abstracts.interfacemethod
|
|
258
|
-
def changelog_status_class(self) ->
|
|
258
|
+
def changelog_status_class(self) -> type[interface.IChangelogStatus]:
|
|
259
259
|
raise NotImplementedError
|
|
260
260
|
|
|
261
261
|
@cached_property
|
|
262
|
-
def changelogs(self) ->
|
|
262
|
+
def changelogs(self) -> tuple[interface.IChangelogStatus, ...]:
|
|
263
263
|
return tuple(
|
|
264
264
|
self.changelog_status_class(self, changelog)
|
|
265
265
|
for changelog
|
|
@@ -4,8 +4,10 @@ import abc
|
|
|
4
4
|
import argparse
|
|
5
5
|
import pathlib
|
|
6
6
|
import re
|
|
7
|
+
from collections.abc import Mapping
|
|
7
8
|
from functools import cached_property
|
|
8
|
-
|
|
9
|
+
|
|
10
|
+
import yaml
|
|
9
11
|
|
|
10
12
|
from yamllint.config import YamlLintConfigError # type:ignore
|
|
11
13
|
|
|
@@ -73,7 +75,7 @@ class ACodeChecker(
|
|
|
73
75
|
return self.args.all_files
|
|
74
76
|
|
|
75
77
|
@cached_property
|
|
76
|
-
def binaries(self) ->
|
|
78
|
+
def binaries(self) -> dict[str, str]:
|
|
77
79
|
return dict(
|
|
78
80
|
binary.split(":")
|
|
79
81
|
for binary
|
|
@@ -91,7 +93,7 @@ class ACodeChecker(
|
|
|
91
93
|
return disabled
|
|
92
94
|
|
|
93
95
|
@property
|
|
94
|
-
def changed_since(self) ->
|
|
96
|
+
def changed_since(self) -> str | None:
|
|
95
97
|
return self.args.since
|
|
96
98
|
|
|
97
99
|
@cached_property
|
|
@@ -103,7 +105,7 @@ class ACodeChecker(
|
|
|
103
105
|
|
|
104
106
|
@property # type:ignore
|
|
105
107
|
@abstracts.interfacemethod
|
|
106
|
-
def changelog_class(self) ->
|
|
108
|
+
def changelog_class(self) -> type["interface.IChangelogCheck"]:
|
|
107
109
|
raise NotImplementedError
|
|
108
110
|
|
|
109
111
|
@cached_property
|
|
@@ -114,6 +116,23 @@ class ACodeChecker(
|
|
|
114
116
|
loop=self.loop,
|
|
115
117
|
pool=self.pool)
|
|
116
118
|
|
|
119
|
+
@cached_property
|
|
120
|
+
def config(self) -> typing.YAMLConfigDict:
|
|
121
|
+
return (
|
|
122
|
+
yaml.safe_load(self.config_path.read_text())
|
|
123
|
+
if self.config_path
|
|
124
|
+
else {})
|
|
125
|
+
|
|
126
|
+
@property
|
|
127
|
+
def config_path(self) -> pathlib.Path | None:
|
|
128
|
+
if not self.args.config:
|
|
129
|
+
return None
|
|
130
|
+
path = pathlib.Path(self.args.config)
|
|
131
|
+
if not path.exists():
|
|
132
|
+
raise exceptions.ConfigurationError(
|
|
133
|
+
f"Config specified but not found: {path}")
|
|
134
|
+
return path
|
|
135
|
+
|
|
117
136
|
@cached_property
|
|
118
137
|
def directory(self) -> "_directory.ADirectory":
|
|
119
138
|
"""Greppable directory - optionally in a git repo, depending on whether
|
|
@@ -122,8 +141,8 @@ class ACodeChecker(
|
|
|
122
141
|
return self.project.directory.filtered(**self.directory_kwargs)
|
|
123
142
|
|
|
124
143
|
@property
|
|
125
|
-
def directory_kwargs(self) ->
|
|
126
|
-
kwargs:
|
|
144
|
+
def directory_kwargs(self) -> dict:
|
|
145
|
+
kwargs: dict = dict(
|
|
127
146
|
exclude_matcher=self.grep_excluding_re,
|
|
128
147
|
path_matcher=self.grep_matching_re,
|
|
129
148
|
untracked=self.all_files)
|
|
@@ -144,7 +163,7 @@ class ACodeChecker(
|
|
|
144
163
|
|
|
145
164
|
@property # type:ignore
|
|
146
165
|
@abstracts.interfacemethod
|
|
147
|
-
def extensions_class(self) ->
|
|
166
|
+
def extensions_class(self) -> type["interface.IExtensionsCheck"]:
|
|
148
167
|
raise NotImplementedError
|
|
149
168
|
|
|
150
169
|
@cached_property
|
|
@@ -154,17 +173,17 @@ class ACodeChecker(
|
|
|
154
173
|
|
|
155
174
|
@property # type:ignore
|
|
156
175
|
@abstracts.interfacemethod
|
|
157
|
-
def flake8_class(self) ->
|
|
176
|
+
def flake8_class(self) -> type["interface.IFlake8Check"]:
|
|
158
177
|
raise NotImplementedError
|
|
159
178
|
|
|
160
179
|
@property # type:ignore
|
|
161
180
|
@abstracts.interfacemethod
|
|
162
|
-
def fs_directory_class(self) ->
|
|
181
|
+
def fs_directory_class(self) -> type["_directory.ADirectory"]:
|
|
163
182
|
raise NotImplementedError
|
|
164
183
|
|
|
165
184
|
@property # type:ignore
|
|
166
185
|
@abstracts.interfacemethod
|
|
167
|
-
def git_directory_class(self) ->
|
|
186
|
+
def git_directory_class(self) -> type["_directory.AGitDirectory"]:
|
|
168
187
|
raise NotImplementedError
|
|
169
188
|
|
|
170
189
|
@cached_property
|
|
@@ -174,7 +193,7 @@ class ACodeChecker(
|
|
|
174
193
|
|
|
175
194
|
@property # type:ignore
|
|
176
195
|
@abstracts.interfacemethod
|
|
177
|
-
def glint_class(self) ->
|
|
196
|
+
def glint_class(self) -> type["interface.IGlintCheck"]:
|
|
178
197
|
raise NotImplementedError
|
|
179
198
|
|
|
180
199
|
@cached_property
|
|
@@ -184,15 +203,15 @@ class ACodeChecker(
|
|
|
184
203
|
|
|
185
204
|
@property # type:ignore
|
|
186
205
|
@abstracts.interfacemethod
|
|
187
|
-
def gofmt_class(self) ->
|
|
206
|
+
def gofmt_class(self) -> type["interface.IGofmtCheck"]:
|
|
188
207
|
raise NotImplementedError
|
|
189
208
|
|
|
190
209
|
@property
|
|
191
|
-
def grep_excluding_re(self) ->
|
|
210
|
+
def grep_excluding_re(self) -> re.Pattern[str] | None:
|
|
192
211
|
return self._grep_re(self.args.excluding)
|
|
193
212
|
|
|
194
213
|
@property
|
|
195
|
-
def grep_matching_re(self) ->
|
|
214
|
+
def grep_matching_re(self) -> re.Pattern[str] | None:
|
|
196
215
|
return self._grep_re(self.args.matching)
|
|
197
216
|
|
|
198
217
|
@property
|
|
@@ -206,19 +225,19 @@ class ACodeChecker(
|
|
|
206
225
|
|
|
207
226
|
@property # type:ignore
|
|
208
227
|
@abstracts.interfacemethod
|
|
209
|
-
def project_class(self) ->
|
|
228
|
+
def project_class(self) -> type[IProject]:
|
|
210
229
|
raise NotImplementedError
|
|
211
230
|
|
|
212
231
|
@cached_property
|
|
213
232
|
def runtime_guards(self) -> "interface.IRuntimeGuardsCheck":
|
|
214
|
-
"""
|
|
233
|
+
"""Runtime guards checker."""
|
|
215
234
|
return self.runtime_guards_class(
|
|
216
235
|
self.project,
|
|
217
236
|
**self.check_kwargs)
|
|
218
237
|
|
|
219
238
|
@property # type:ignore
|
|
220
239
|
@abstracts.interfacemethod
|
|
221
|
-
def runtime_guards_class(self) ->
|
|
240
|
+
def runtime_guards_class(self) -> type["interface.IRuntimeGuardsCheck"]:
|
|
222
241
|
raise NotImplementedError
|
|
223
242
|
|
|
224
243
|
@cached_property
|
|
@@ -228,11 +247,11 @@ class ACodeChecker(
|
|
|
228
247
|
|
|
229
248
|
@property # type:ignore
|
|
230
249
|
@abstracts.interfacemethod
|
|
231
|
-
def shellcheck_class(self) ->
|
|
250
|
+
def shellcheck_class(self) -> type["interface.IShellcheckCheck"]:
|
|
232
251
|
raise NotImplementedError
|
|
233
252
|
|
|
234
253
|
@property
|
|
235
|
-
def summary_class(self) ->
|
|
254
|
+
def summary_class(self) -> type[CodeCheckerSummary]:
|
|
236
255
|
"""CodeChecker's summary class."""
|
|
237
256
|
return CodeCheckerSummary
|
|
238
257
|
|
|
@@ -243,7 +262,7 @@ class ACodeChecker(
|
|
|
243
262
|
|
|
244
263
|
@property # type:ignore
|
|
245
264
|
@abstracts.interfacemethod
|
|
246
|
-
def yamllint_class(self) ->
|
|
265
|
+
def yamllint_class(self) -> type[interface.IYamllintCheck]:
|
|
247
266
|
raise NotImplementedError
|
|
248
267
|
|
|
249
268
|
@cached_property
|
|
@@ -253,7 +272,7 @@ class ACodeChecker(
|
|
|
253
272
|
|
|
254
273
|
@property # type:ignore
|
|
255
274
|
@abstracts.interfacemethod
|
|
256
|
-
def yapf_class(self) ->
|
|
275
|
+
def yapf_class(self) -> type[interface.IYapfCheck]:
|
|
257
276
|
raise NotImplementedError
|
|
258
277
|
|
|
259
278
|
def add_arguments(self, parser: argparse.ArgumentParser) -> None:
|
|
@@ -263,6 +282,11 @@ class ACodeChecker(
|
|
|
263
282
|
parser.add_argument("-x", "--excluding", action="append")
|
|
264
283
|
parser.add_argument("-b", "--binary", action="append")
|
|
265
284
|
parser.add_argument("-s", "--since")
|
|
285
|
+
parser.add_argument(
|
|
286
|
+
"--config",
|
|
287
|
+
default="./tools/code/config.yaml",
|
|
288
|
+
help=("specify the config path. "
|
|
289
|
+
"Default './tools/code/config.yaml'."))
|
|
266
290
|
parser.add_argument("--codeowners")
|
|
267
291
|
parser.add_argument("--owners")
|
|
268
292
|
parser.add_argument("--extensions_build_config")
|
|
@@ -278,7 +302,7 @@ class ACodeChecker(
|
|
|
278
302
|
[f"{changelog.version}"])
|
|
279
303
|
|
|
280
304
|
async def check_extensions_fuzzed(self) -> None:
|
|
281
|
-
"""Check
|
|
305
|
+
"""Check that all fuzzed extensions are accounted for."""
|
|
282
306
|
if await self.extensions.all_fuzzed:
|
|
283
307
|
self.succeed(
|
|
284
308
|
"extensions_fuzzed",
|
|
@@ -291,7 +315,7 @@ class ACodeChecker(
|
|
|
291
315
|
f"in {self.extensions.fuzz_test_path}"])
|
|
292
316
|
|
|
293
317
|
async def check_extensions_metadata(self) -> None:
|
|
294
|
-
"""Check
|
|
318
|
+
"""Check extensions metadata."""
|
|
295
319
|
errors = await self.extensions.metadata_errors
|
|
296
320
|
for extension, errors in errors.items():
|
|
297
321
|
if errors:
|
|
@@ -300,7 +324,7 @@ class ACodeChecker(
|
|
|
300
324
|
self.succeed("extensions_metadata", [f"{extension}"])
|
|
301
325
|
|
|
302
326
|
async def check_extensions_owners(self) -> None:
|
|
303
|
-
"""Check
|
|
327
|
+
"""Check extensions owners."""
|
|
304
328
|
checks = await self.extensions.owners_errors
|
|
305
329
|
for extension, errors in sorted(checks.items()):
|
|
306
330
|
if errors:
|
|
@@ -309,7 +333,7 @@ class ACodeChecker(
|
|
|
309
333
|
self.succeed("extensions_owners", [f"{extension}"])
|
|
310
334
|
|
|
311
335
|
async def check_extensions_registered(self) -> None:
|
|
312
|
-
"""Check
|
|
336
|
+
"""Check extensions are registered."""
|
|
313
337
|
if errors := await self.extensions.registration_errors:
|
|
314
338
|
self.error("extensions_registered", errors)
|
|
315
339
|
else:
|
|
@@ -335,7 +359,8 @@ class ACodeChecker(
|
|
|
335
359
|
await self._code_check(self.yapf)
|
|
336
360
|
|
|
337
361
|
async def check_runtime_guards(self) -> None:
|
|
338
|
-
"""Check
|
|
362
|
+
"""Check runtime guards."""
|
|
363
|
+
|
|
339
364
|
async for guard, status in self.runtime_guards.status:
|
|
340
365
|
if status is None:
|
|
341
366
|
self.log.info(f"Ignoring runtime guard: {guard}")
|
|
@@ -427,7 +452,7 @@ class ACodeChecker(
|
|
|
427
452
|
|
|
428
453
|
def _check_output(
|
|
429
454
|
self,
|
|
430
|
-
check_files:
|
|
455
|
+
check_files: set[str],
|
|
431
456
|
problem_files: typing.ProblemDict) -> None:
|
|
432
457
|
# This can be slow/blocking for large result sets, run
|
|
433
458
|
# in a separate thread
|
|
@@ -453,7 +478,7 @@ class ACodeChecker(
|
|
|
453
478
|
await check.files,
|
|
454
479
|
await check.problem_files)
|
|
455
480
|
|
|
456
|
-
def _grep_re(self, arg:
|
|
481
|
+
def _grep_re(self, arg: str | None) -> re.Pattern[str] | None:
|
|
457
482
|
# When using system `grep` we want to filter out at least some
|
|
458
483
|
# of the files that .gitignore would.
|
|
459
484
|
# TODO: use globs on cli and covert to re here
|