Skip to content

Commit fd6af64

Browse files
Fixed the good first issue
1 parent f9ad372 commit fd6af64

File tree

4 files changed

+108
-4
lines changed

4 files changed

+108
-4
lines changed

docs/source/conf.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939

4040
# Redirects for olds pages
4141
# See https://documatt.gitlab.io/sphinx-reredirects/usage.html
42-
redirects = {}
42+
# redirects = {}
43+
redirects: dict[str, str] = {}
4344

4445
# This points to aboutcode.readthedocs.io
4546
# In case of "undefined label" ERRORS check docs on intersphinx to troubleshoot
@@ -60,8 +61,8 @@
6061
# List of patterns, relative to source directory, that match files and
6162
# directories to ignore when looking for source files.
6263
# This pattern also affects html_static_path and html_extra_path.
63-
exclude_patterns = []
64-
64+
# exclude_patterns = []
65+
exclude_patterns: list[str] = []
6566

6667
# -- Options for HTML output -------------------------------------------------
6768

mypy.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[mypy]
2+
exclude = venv/|.venv/|build/|dist/
3+
ignore_missing_imports = True

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ build-backend = "setuptools.build_meta"
88
fallback_version = "9999.$Format:%h-%cs$"
99

1010
[tool.pytest.ini_options]
11+
python_files = "test_*.py"
1112
norecursedirs = [
1213
".git",
1314
"bin",
@@ -40,7 +41,7 @@ norecursedirs = [
4041
"tests/*/data"
4142
]
4243

43-
python_files = "*.py"
44+
#python_files = "*.py"
4445

4546
python_classes = "Test"
4647
python_functions = "test"

up.py

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
from __future__ import annotations
2+
import argparse
3+
import shutil
4+
import subprocess
5+
import sys
6+
from pathlib import Path
7+
from typing import List
8+
9+
PYTHON = sys.executable
10+
ROOT = Path(__file__).resolve().parent
11+
12+
13+
def run(cmd: List[str], dry: bool = False):
14+
print("+", " ".join(cmd))
15+
if dry:
16+
return 0
17+
return subprocess.call(cmd)
18+
19+
20+
def ensure(tool: str):
21+
return shutil.which(tool) is not None
22+
23+
24+
def cmd_test(dry):
25+
# pytest preferred
26+
if ensure("pytest"):
27+
return run([PYTHON, "-m", "pytest"], dry)
28+
return run([PYTHON, "-m", "unittest", "discover", "-v"], dry)
29+
30+
31+
def cmd_lint(dry):
32+
if ensure("ruff"):
33+
return run(["ruff", "check", "."], dry)
34+
if ensure("flake8"):
35+
return run(["flake8", "."], dry)
36+
if ensure("pylint"):
37+
# auto-detect python packages in repo
38+
packages = [p.name for p in ROOT.iterdir() if (p / "__init__.py").exists()]
39+
if packages:
40+
return run(["pylint"] + packages, dry)
41+
return run(["pylint", "."], dry)
42+
print("No linter installed.")
43+
return 1
44+
45+
46+
def cmd_format(dry):
47+
if ensure("black"):
48+
return run(["black", "."], dry)
49+
print("Black not installed.")
50+
return 1
51+
52+
53+
def cmd_mypy(dry):
54+
if ensure("mypy"):
55+
return run(["mypy", "."], dry)
56+
print("mypy not installed.")
57+
return 1
58+
59+
60+
def cmd_docs(dry):
61+
if ensure("sphinx-build"):
62+
return run(["sphinx-build", "docs", "docs/_build"], dry)
63+
print("Sphinx not installed.")
64+
return 1
65+
66+
67+
def main():
68+
parser = argparse.ArgumentParser()
69+
parser.add_argument(
70+
"command",
71+
nargs="?",
72+
default="help",
73+
choices=["help", "test", "lint", "format", "mypy", "docs", "all"],
74+
)
75+
parser.add_argument("--dry-run", action="store_true")
76+
args = parser.parse_args()
77+
78+
cmds = {
79+
"test": [cmd_test],
80+
"lint": [cmd_lint],
81+
"format": [cmd_format],
82+
"mypy": [cmd_mypy],
83+
"docs": [cmd_docs],
84+
"all": [cmd_format, cmd_lint, cmd_mypy, cmd_test, cmd_docs],
85+
}
86+
87+
if args.command == "help":
88+
parser.print_help()
89+
return
90+
91+
for task in cmds[args.command]:
92+
rc = task(args.dry_run)
93+
if rc:
94+
sys.exit(rc)
95+
96+
sys.exit(0)
97+
98+
if __name__ == "__main__":
99+
main()

0 commit comments

Comments
 (0)