Skip to content

fix: fix errors in stubs #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ ci:
files: "examples|tests"
repos:
- repo: https://github.com/crate-ci/typos
rev: v1.30.0
rev: v1.31.1
hooks:
- id: typos

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.9.9
rev: v0.11.7
hooks:
- id: ruff
args: [--fix, --unsafe-fixes]
- id: ruff-format

- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.23
rev: v0.24.1
hooks:
- id: validate-pyproject
24 changes: 23 additions & 1 deletion project.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import os
import re
import shutil
from pathlib import Path

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

# rename _ads.pyi to __init__.pyi
(package / "_ads.pyi").rename(package / "__init__.pyi")
stubs = package / "_ads.pyi"
stubs = stubs.rename(package / "__init__.pyi")

# fix some errors in the stubs
stubs_src = stubs.read_text()
# replace erroneous [...*] syntax
stubs_src = stubs_src.replace("*]", "]")
stubs_src = stubs_src.replace(" Any", " typing.Any")
# remove all of the ` = ... # type: ` enum type hints
stubs_src = re.sub(r"=\s*\.\.\.\s*#\s*type:\s*\S+", "= ...", stubs_src)

stubs.write_text(stubs_src)
if shutil.which("ruff"):
import subprocess

subprocess.run(
["ruff", "check", str(stubs), "--fix-only", "--select", "E,F,W,I,TC"]
)
subprocess.run(["ruff", "format", str(stubs), "--line-length", "110"])

(package / "py.typed").touch()


class PyQt6Ads(PyQtProject):
def __init__(self):
super().__init__()
Expand Down
12 changes: 6 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Specify the build system.
[build-system]
requires = ["sip >=6,<7", "PyQt-builder >=1.17,<2", "PyQt6==6.5.3"]
requires = ["sip >=6,<7", "PyQt-builder >=1.17,<2", "PyQt6==6.5.3", "ruff"]
build-backend = "sipbuild.api"

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

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

[tool.cibuildwheel.windows]
before-build = "uvx --from aqtinstall aqt install-qt windows desktop %QT_VERSION% win64_msvc2019_64 --outputdir Qt --base http://mirrors.ocf.berkeley.edu/qt/"
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/"


# https://docs.astral.sh/ruff/
Expand Down
Loading