Skip to content

Commit 90e5a3e

Browse files
authored
chore: run hatch fmt (#44)
Signed-off-by: Henry Schreiner <[email protected]>
1 parent 5af54d9 commit 90e5a3e

File tree

7 files changed

+295
-254
lines changed

7 files changed

+295
-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 & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,16 @@
44
(Docs WIP).
55
"""
66

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

11+
from pybind11_mkdoc.mkdoc_lib import mkdoc
1612

1713
__version__ = "2.6.2.dev1"
1814

1915

20-
def _append_include_dir(args: list, include_dir: str, verbose: bool = True):
16+
def _append_include_dir(args: list, include_dir: str, *, verbose: bool = True):
2117
"""
2218
Add an include directory to an argument list (if it exists).
2319
@@ -37,10 +33,10 @@ def _append_include_dir(args: list, include_dir: str, verbose: bool = True):
3733
if os.path.isdir(include_dir):
3834
args.append(f"-I{include_dir}")
3935
elif verbose:
40-
print(f"Include directory {include_dir!r} does not exist!")
36+
pass
4137

4238

43-
def _append_definition(args: list, definition: str, verbose: bool = True):
39+
def _append_definition(args: list, definition: str):
4440
"""
4541
Add a compiler definition to an argument list.
4642
@@ -61,21 +57,20 @@ def _append_definition(args: list, definition: str, verbose: bool = True):
6157
"""
6258

6359
try:
64-
macro, _, value = definition.partition('=')
60+
macro, _, value = definition.partition("=")
6561
macro = macro.strip()
66-
value = value.strip() if value else '1'
62+
value = value.strip() if value else "1"
6763

6864
args.append(f"-D{macro}={value}")
69-
except ValueError as exc:
65+
except ValueError:
7066
# most likely means there was no '=' given
7167
# check if argument is valid identifier
72-
if re.search(r'^[A-Za-z_][A-Za-z0-9_]*', definition):
68+
if re.search(r"^[A-Za-z_][A-Za-z0-9_]*", definition):
7369
args.append(f"-D{definition}")
7470
else:
75-
print(f"Failed to parse definition: {definition}")
76-
except:
77-
print(f"Failed to parse definition: {definition}")
78-
71+
pass
72+
except Exception:
73+
pass
7974

8075

8176
def main():
@@ -86,26 +81,53 @@ def main():
8681
"""
8782

8883
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)
84+
prog="pybind11_mkdoc",
85+
description="Processes a sequence of C/C++ headers and extracts comments for use in pybind11 binding code.",
86+
epilog="(Other compiler flags that Clang understands can also be supplied)",
87+
allow_abbrev=False,
88+
)
9389

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

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

110132
[parsed_args, unparsed_args] = parser.parse_known_args()
111133

@@ -130,8 +152,7 @@ def main():
130152
# append argument as is and hope for the best
131153
mkdoc_args.append(arg)
132154

133-
for header in parsed_args.header:
134-
mkdoc_args.append(header)
155+
mkdoc_args.extend(header for header in parsed_args.header)
135156

136157
mkdoc(mkdoc_args, docstring_width, mkdoc_out)
137158

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)