Skip to content

Commit a9f02ca

Browse files
authored
fix: fix errors in stubs (#13)
* fix: fix errors in stubs * update pre-commit * pin aqtinstall * remove quotes
1 parent ef88af3 commit a9f02ca

File tree

4 files changed

+129
-105
lines changed

4 files changed

+129
-105
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@ ci:
66
files: "examples|tests"
77
repos:
88
- repo: https://github.com/crate-ci/typos
9-
rev: v1.30.0
9+
rev: v1.31.1
1010
hooks:
1111
- id: typos
1212

1313
- repo: https://github.com/astral-sh/ruff-pre-commit
14-
rev: v0.9.9
14+
rev: v0.11.7
1515
hooks:
1616
- id: ruff
1717
args: [--fix, --unsafe-fixes]
1818
- id: ruff-format
1919

2020
- repo: https://github.com/abravalheri/validate-pyproject
21-
rev: v0.23
21+
rev: v0.24.1
2222
hooks:
2323
- id: validate-pyproject

project.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import os
2+
import re
3+
import shutil
24
from pathlib import Path
35

46
from pyqtbuild import PyQtBindings, PyQtProject, QmakeBuilder
@@ -25,9 +27,29 @@ def install_project(self, target_dir, *, wheel_tag=None):
2527
(package / "__init__.py").write_text(contents)
2628

2729
# rename _ads.pyi to __init__.pyi
28-
(package / "_ads.pyi").rename(package / "__init__.pyi")
30+
stubs = package / "_ads.pyi"
31+
stubs = stubs.rename(package / "__init__.pyi")
32+
33+
# fix some errors in the stubs
34+
stubs_src = stubs.read_text()
35+
# replace erroneous [...*] syntax
36+
stubs_src = stubs_src.replace("*]", "]")
37+
stubs_src = stubs_src.replace(" Any", " typing.Any")
38+
# remove all of the ` = ... # type: ` enum type hints
39+
stubs_src = re.sub(r"=\s*\.\.\.\s*#\s*type:\s*\S+", "= ...", stubs_src)
40+
41+
stubs.write_text(stubs_src)
42+
if shutil.which("ruff"):
43+
import subprocess
44+
45+
subprocess.run(
46+
["ruff", "check", str(stubs), "--fix-only", "--select", "E,F,W,I,TC"]
47+
)
48+
subprocess.run(["ruff", "format", str(stubs), "--line-length", "110"])
49+
2950
(package / "py.typed").touch()
3051

52+
3153
class PyQt6Ads(PyQtProject):
3254
def __init__(self):
3355
super().__init__()

pyproject.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# Specify the build system.
22
[build-system]
3-
requires = ["sip >=6,<7", "PyQt-builder >=1.17,<2", "PyQt6==6.5.3"]
3+
requires = ["sip >=6,<7", "PyQt-builder >=1.17,<2", "PyQt6==6.5.3", "ruff"]
44
build-backend = "sipbuild.api"
55

66
# Specify the PEP 566 metadata for the project.
77
[project]
88
name = "PyQt6Ads"
99
# TODO: make dynamic in project.py
10-
version = "4.4.0.post1"
10+
version = "4.4.0.post2"
1111
requires-python = ">=3.9"
1212
description = "Python bindings for Qt Advanced Docking System"
1313
license = { text = "LGPL v2.1" }
@@ -124,22 +124,22 @@ test-groups = ["test"]
124124
environment-pass = ["QT_VERSION"]
125125
before-build = [
126126
"yum install -y libxkbcommon-devel",
127-
"uvx --from aqtinstall aqt install-qt linux desktop $QT_VERSION --outputdir Qt --base http://mirrors.ocf.berkeley.edu/qt/",
127+
"uvx --from aqtinstall==3.2.0 aqt install-qt linux desktop $QT_VERSION --outputdir Qt --base http://mirrors.ocf.berkeley.edu/qt/",
128128
]
129129
repair-wheel-command = ["python scripts/repair_wheel.py {dest_dir} {wheel}"]
130130
test-command = [
131131
"yum install -y epel-release",
132132
"yum install -y libxkbcommon-x11 xcb-util-cursor xcb-util-wm xcb-util-keysyms xorg-x11-server-Xvfb",
133133
"uv pip install pytest-xvfb",
134-
"pytest {project}/tests -v"
134+
"pytest {project}/tests -v",
135135
]
136136

137137
[tool.cibuildwheel.macos]
138-
before-build = "uvx --from aqtinstall aqt install-qt mac desktop $QT_VERSION --outputdir Qt --base http://mirrors.ocf.berkeley.edu/qt/"
138+
before-build = "uvx --from aqtinstall==3.2.0 aqt install-qt mac desktop $QT_VERSION --outputdir Qt --base http://mirrors.ocf.berkeley.edu/qt/"
139139
repair-wheel-command = ["python scripts/repair_wheel.py {dest_dir} {wheel}"]
140140

141141
[tool.cibuildwheel.windows]
142-
before-build = "uvx --from aqtinstall aqt install-qt windows desktop %QT_VERSION% win64_msvc2019_64 --outputdir Qt --base http://mirrors.ocf.berkeley.edu/qt/"
142+
before-build = "uvx --from aqtinstall==3.2.0 aqt install-qt windows desktop %QT_VERSION% win64_msvc2019_64 --outputdir Qt --base http://mirrors.ocf.berkeley.edu/qt/"
143143

144144

145145
# https://docs.astral.sh/ruff/

0 commit comments

Comments
 (0)