Skip to content

Commit 9a289a4

Browse files
committed
chore: run hatch fmt
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
1 parent b284c4b commit 9a289a4

File tree

7 files changed

+291
-254
lines changed

7 files changed

+291
-254
lines changed

.github/workflows/ci.yml

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ on:
99
- 'v*'
1010

1111
jobs:
12+
format:
13+
runs-on: ubuntu-latest
14+
name: Format
15+
steps:
16+
- uses: actions/checkout@v5
17+
- uses: astral-sh/setup-uv@v7
18+
- run: uvx hatch fmt
19+
1220
checks:
1321
strategy:
1422
fail-fast: false
@@ -27,12 +35,10 @@ jobs:
2735
- uses: actions/setup-python@v6
2836
with:
2937
python-version: ${{ matrix.python-version }}
30-
31-
- name: Install package
32-
run: python -m pip install .[test] "clang<19"
38+
- uses: astral-sh/setup-uv@v7
3339

3440
- name: Test package
35-
run: python -m pytest --forked
41+
run: uv run --with "clang<19" --extra test pytest --forked
3642

3743
# Commented for now -- msys2 Clang (v15) and the clang Python package (v14) are incompatible
3844
#
@@ -69,12 +75,4 @@ jobs:
6975
name: Build distribution
7076
steps:
7177
- uses: actions/checkout@v5
72-
- uses: actions/setup-python@v6
73-
74-
- name: Build
75-
run: pipx run build
76-
77-
- uses: actions/upload-artifact@v5
78-
with:
79-
name: DistPackage
80-
path: dist
78+
- uses: hynek/build-and-inspect-python-package@v2

pybind11_mkdoc/__init__.py

Lines changed: 56 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,17 @@
44
(Docs WIP).
55
"""
66

7-
87
import argparse
98
import os
109
import re
1110
import shlex
12-
import sys
13-
14-
from .mkdoc_lib import mkdoc
1511

12+
from pybind11_mkdoc.mkdoc_lib import mkdoc
1613

1714
__version__ = "2.6.2.dev1"
1815

1916

20-
def _append_include_dir(args: list, include_dir: str, verbose: bool = True):
17+
def _append_include_dir(args: list, include_dir: str, *, verbose: bool = True):
2118
"""
2219
Add an include directory to an argument list (if it exists).
2320
@@ -37,10 +34,10 @@ def _append_include_dir(args: list, include_dir: str, verbose: bool = True):
3734
if os.path.isdir(include_dir):
3835
args.append(f"-I{shlex.quote(include_dir)}")
3936
elif verbose:
40-
print(f"Include directoy '{shlex.quote(include_dir)}' does not exist!")
37+
pass
4138

4239

43-
def _append_definition(args: list, definition: str, verbose: bool = True):
40+
def _append_definition(args: list, definition: str):
4441
"""
4542
Add a compiler definition to an argument list.
4643
@@ -61,21 +58,20 @@ def _append_definition(args: list, definition: str, verbose: bool = True):
6158
"""
6259

6360
try:
64-
macro, value = definition.strip().split('=')
61+
macro, value = definition.strip().split("=")
6562
macro = shlex.quote(macro.strip())
66-
value = shlex.quote(value.strip()) if value else '1'
63+
value = shlex.quote(value.strip()) if value else "1"
6764

6865
args.append(f"-D{macro}={value}")
69-
except ValueError as exc:
66+
except ValueError:
7067
# most likely means there was no '=' given
7168
# check if argument is valid identifier
72-
if re.search(r'^[A-Za-z_][A-Za-z0-9_]*', definition):
69+
if re.search(r"^[A-Za-z_][A-Za-z0-9_]*", definition):
7370
args.append(f"-D{definition}")
7471
else:
75-
print(f"Failed to parse definition: {shlex.quote(definition)}")
76-
except:
77-
print(f"Failed to parse definition: {shlex.quote(definition)}")
78-
72+
pass
73+
except Exception:
74+
pass
7975

8076

8177
def main():
@@ -86,26 +82,53 @@ def main():
8682
"""
8783

8884
parser = argparse.ArgumentParser(
89-
prog='pybind11_mkdoc',
90-
description="Processes a sequence of C/C++ headers and extracts comments for use in pybind11 binding code.",
91-
epilog="(Other compiler flags that Clang understands can also be supplied)",
92-
allow_abbrev=False)
85+
prog="pybind11_mkdoc",
86+
description="Processes a sequence of C/C++ headers and extracts comments for use in pybind11 binding code.",
87+
epilog="(Other compiler flags that Clang understands can also be supplied)",
88+
allow_abbrev=False,
89+
)
9390

9491
parser.add_argument("-v", "--version", action="version", version=f"%(prog)s {__version__}")
9592

96-
parser.add_argument("-o", "--output", action="store", type=str, dest="output", metavar="<file>",
97-
help="Write to the specified file (default: use stdout).")
98-
99-
parser.add_argument("-w", "--width", action="store", type=int, dest="width", metavar="<width>",
100-
help="Specify docstring width before wrapping.")
101-
102-
parser.add_argument("-I", action="append", type=str, dest="include_dirs", metavar="<dir>",
103-
help="Specify an directory to add to the list of include search paths.")
104-
105-
parser.add_argument("-D", action="append", type=str, metavar="<macro>=<value>", dest="definitions",
106-
help="Specify a compiler definition, i.e. define <macro> to <value> (or 1 if <value> omitted).")
107-
108-
parser.add_argument("header", type=str, nargs='+', help="A header file to process.")
93+
parser.add_argument(
94+
"-o",
95+
"--output",
96+
action="store",
97+
type=str,
98+
dest="output",
99+
metavar="<file>",
100+
help="Write to the specified file (default: use stdout).",
101+
)
102+
103+
parser.add_argument(
104+
"-w",
105+
"--width",
106+
action="store",
107+
type=int,
108+
dest="width",
109+
metavar="<width>",
110+
help="Specify docstring width before wrapping.",
111+
)
112+
113+
parser.add_argument(
114+
"-I",
115+
action="append",
116+
type=str,
117+
dest="include_dirs",
118+
metavar="<dir>",
119+
help="Specify an directory to add to the list of include search paths.",
120+
)
121+
122+
parser.add_argument(
123+
"-D",
124+
action="append",
125+
type=str,
126+
metavar="<macro>=<value>",
127+
dest="definitions",
128+
help="Specify a compiler definition, i.e. define <macro> to <value> (or 1 if <value> omitted).",
129+
)
130+
131+
parser.add_argument("header", type=str, nargs="+", help="A header file to process.")
109132

110133
[parsed_args, unparsed_args] = parser.parse_known_args()
111134

@@ -130,8 +153,7 @@ def main():
130153
# append argument as is and hope for the best
131154
mkdoc_args.append(shlex.quote(arg))
132155

133-
for header in parsed_args.header:
134-
mkdoc_args.append(shlex.quote(header))
156+
mkdoc_args.extend(shlex.quote(header) for header in parsed_args.header)
135157

136158
mkdoc(mkdoc_args, docstring_width, mkdoc_out)
137159

pybind11_mkdoc/__main__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
21
if __name__ == "__main__":
3-
from . import main
4-
main()
2+
from pybind11_mkdoc import main
53

4+
main()

0 commit comments

Comments
 (0)