File tree Expand file tree Collapse file tree 7 files changed +30
-4
lines changed
Expand file tree Collapse file tree 7 files changed +30
-4
lines changed Original file line number Diff line number Diff line change 4545 python -m pip install --upgrade pip
4646 echo "PySide6==${{ matrix.pyside6_version }}" > constraint.txt
4747 pip install -r requirements.txt -c constraint.txt
48+ hatch build --hooks-only
4849 - name : Check formatting with black
4950 run : |
5051 black --check .
Original file line number Diff line number Diff line change @@ -54,6 +54,8 @@ Generate QML stub files (.qmltypes) from Python modules (which use PySide6)
5454
5555Usage:
5656 pyside6-qml-stubgen < in-dir> ... --out-dir=< out-dir> [--ignore=< path> ...] [--metatypes-dir=< dir> ] [--qmltyperegistrar-path=< path> ] [--force-rebuild] [--file-relative-path=< div> ] [--extra-external-modules=< modules> ]
57+ pyside6-qml-stubgen (-h | --help)
58+ pyside6-qml-stubgen --version
5759
5860Options:
5961 --ignore=< path> Ignore all Python files that are children of this path
@@ -63,4 +65,6 @@ Options:
6365 --file-relative-path=< div> Make all paths in generated type files relative to this path
6466 (useful for if the generated stubs need to be used on different systems)
6567 --extra-external-modules=< modules> Additional modules which should be assumed to contain QML exposed types (comma separated)
68+ -h --help Show this screen
69+ --version Show version
6670` ` `
Original file line number Diff line number Diff line change @@ -38,6 +38,9 @@ build-backend = "hatchling.build"
3838[tool .hatch .version ]
3939source = " vcs"
4040
41+ [tool .hatch .build .hooks .vcs ]
42+ version-file = " pyside6_qml_stubgen/_version.py"
43+
4144[tool .mypy ]
4245python_version = " 3.10"
4346warn_unused_configs = true
@@ -50,3 +53,6 @@ warn_unused_ignores = true
5053warn_unreachable = true
5154strict_equality = true
5255local_partial_types = true
56+
57+ [tool .black ]
58+ extend-exclude = " _version.py"
Original file line number Diff line number Diff line change 1313from PySide6 import QtCore
1414
1515from . import dirty_file_detection , pyside_patching , qmlregistrar_types
16+ from ._version import __version__ , __version_tuple__
1617
1718
1819def parse_module (
@@ -267,7 +268,10 @@ def import_dirty_modules(
267268 )
268269
269270 dirty_file_detection .save_modules_metadata (
270- out_dir , dirty_file_detection .PythonModulesMetadata (module_metadata )
271+ out_dir ,
272+ dirty_file_detection .PythonModulesMetadata (
273+ module_metadata , generating_version = __version__
274+ ),
271275 )
272276
273277 extra_info .resolve_delayed ()
Original file line number Diff line number Diff line change 33
44Usage:
55 pyside6-qml-stubgen <in-dir>... --out-dir=<out-dir> [--ignore=<path>...] [--metatypes-dir=<dir>] [--qmltyperegistrar-path=<path>] [--force-rebuild] [--file-relative-path=<div>] [--extra-external-modules=<modules>]
6+ pyside6-qml-stubgen (-h | --help)
7+ pyside6-qml-stubgen --version
68
79Options:
810 --ignore=<path> Ignore all Python files that are children of this path
1214 --file-relative-path=<div> Make all paths in generated type files relative to this path
1315 (useful for if the generated stubs need to be used on different systems)
1416 --extra-external-modules=<modules> Additional modules which should be assumed to contain QML exposed types (comma separated)
17+ -h --help Show this screen
18+ --version Show version
1519"""
1620
1721import pathlib
1822
1923import docopt
2024
21- from . import process
25+ from . import _version , process
2226
2327
2428def main () -> None :
25- args = docopt .docopt (__doc__ )
29+ args = docopt .docopt (__doc__ , version = _version . __version__ )
2630 process (
2731 in_dirs = [pathlib .Path (p ) for p in args ["<in-dir>" ]],
2832 ignore_dirs = [pathlib .Path (ig ) for ig in args ["--ignore" ]],
Original file line number Diff line number Diff line change 55
66import pydantic
77
8+ from . import _version
9+
810
911@dataclasses .dataclass
1012class PythonModuleMetadata :
@@ -16,16 +18,19 @@ class PythonModuleMetadata:
1618@dataclasses .dataclass
1719class PythonModulesMetadata :
1820 modules : typing .Mapping [str , PythonModuleMetadata | None ]
21+ generating_version : str = ""
1922
2023
2124PYTHON_MODULES_METADATA_TYPE_ADAPTER = pydantic .TypeAdapter (PythonModulesMetadata )
2225
2326
2427def load_modules_metadata (dir_path : pathlib .Path ) -> PythonModulesMetadata :
2528 if (dir_path / "metadata.json" ).exists ():
26- return PYTHON_MODULES_METADATA_TYPE_ADAPTER .validate_json (
29+ metadata = PYTHON_MODULES_METADATA_TYPE_ADAPTER .validate_json (
2730 (dir_path / "metadata.json" ).read_bytes ()
2831 )
32+ if metadata .generating_version == _version .__version__ :
33+ return metadata
2934 return PythonModulesMetadata ({})
3035
3136
Original file line number Diff line number Diff line change @@ -22,3 +22,5 @@ PySide6
2222PySide6_Addons
2323PySide6_Essentials
2424shiboken6
25+ hatch
26+ hatch-vcs
You can’t perform that action at this time.
0 commit comments