Skip to content

Commit b173faa

Browse files
committed
Working tox and basic testing
1 parent bb5509f commit b173faa

File tree

5 files changed

+139
-14
lines changed

5 files changed

+139
-14
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
runs-on: ubuntu-latest
1515
strategy:
1616
matrix:
17-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
17+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
1818

1919
steps:
2020
- name: Checkout Code
@@ -38,5 +38,8 @@ jobs:
3838
- name: Run Unit Tests
3939
run: uv run pytest -v
4040

41+
- name: Run StubTest
42+
run: uv run stubtest pyslang --allowlist allowlist.txt
43+
4144
- name: Test Package Build
4245
run: uv build

pyproject.toml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "uv_build"
44

55
[project]
66
name = "pyslang-stubs"
7-
version = "9.0.0"
7+
version = "9.0.0.20250901-b0"
88
description = "Typing stubs for the excellent pyslang library"
99
readme = "README.md"
1010
authors = [
@@ -16,7 +16,7 @@ classifiers = [
1616
"Classifier: Typing :: Stubs Only"
1717
]
1818

19-
requires-python = ">=3.13"
19+
requires-python = ">=3.9"
2020
dependencies = [
2121
"typing-extensions>=4.15.0",
2222
]
@@ -57,7 +57,7 @@ typeCheckingMode = "basic"
5757
line-length = 100
5858
indent-width = 4
5959

60-
target-version = "py38"
60+
target-version = "py39"
6161
show-fixes = true
6262

6363
src = ["src"]
@@ -84,10 +84,10 @@ ignore = [
8484

8585
[tool.tox]
8686
env_list = [
87-
"py3.13", "py3.12", "py3.11", "py3.10", "py3.9", "py3.8",
87+
"py3.13", "py3.12", "py3.11", "py3.10", "py3.9",
8888
"style",
8989
"typing",
90-
# "docs",
90+
"stubs",
9191
]
9292

9393
[tool.tox.env_run_base]
@@ -97,7 +97,7 @@ package = "wheel"
9797
wheel_build_env = ".pkg"
9898
constrain_package_deps = true
9999
use_frozen_constraints = true
100-
dependency_groups = ["tests"]
100+
dependency_groups = ["dev"]
101101

102102
commands = [[
103103
"pytest", "-v", "--tb=short", "--basetemp={env_tmp_dir}",
@@ -116,3 +116,11 @@ dependency_groups = ["dev"]
116116
commands = [
117117
["mypy"],
118118
]
119+
120+
[tool.tox.env.stubs]
121+
description = "run stub checking"
122+
dependency_groups = ["dev"]
123+
set_env = {MYPYPATH = "./stubs/"}
124+
commands = [
125+
["stubtest", "pyslang", "--allowlist", "allowlist.txt"]
126+
]

src/pyslang-stubs/__init__.pyi

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@ from typing import Any, ClassVar, Final
1111
from typing_extensions import Self
1212

1313
try:
14-
from pybind11_builtins import ( # pyright: ignore[reportMissingImports]
15-
pybind11_type as _metaclass,
16-
)
14+
from pybind11_builtins import pybind11_type as _metaclass # type: ignore
1715
except ImportError:
18-
_metaclass = type
16+
_metaclass = type # type: ignore
1917

2018
class ASTFlags(metaclass=_metaclass):
2119
AllowClockingBlock: ClassVar[ASTFlags]
@@ -6766,7 +6764,7 @@ class ScopedNameSyntax(NameSyntax):
67666764

67676765
class ScriptSession(metaclass=_metaclass):
67686766
def __init__(self) -> None: ...
6769-
def eval(self, text: str) -> Any: ...
6767+
def eval(self, text: str) -> ConstantValue: ...
67706768
def evalExpression(self, expr: Any) -> Any: ...
67716769
def evalStatement(self, expr: Any) -> None: ...
67726770
def getDiagnostics(self) -> Any: ...

tests/test_typing.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from __future__ import annotations
2+
3+
4+
import pyslang
5+
6+
7+
def test_script_session():
8+
evaluation = pyslang.ScriptSession()
9+
assert isinstance(evaluation, pyslang.ScriptSession)
10+
11+
result = evaluation.eval("8'hFF")
12+
assert isinstance(result, pyslang.ConstantValue)

0 commit comments

Comments
 (0)