Skip to content

Commit b2ea40a

Browse files
committed
🔖First full release. Added some more typing information
1 parent f31875d commit b2ea40a

File tree

5 files changed

+45
-16
lines changed

5 files changed

+45
-16
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,10 @@ This version of `stubs-pyslang` aims to provide accurate annotations for `pyslan
1212

1313
This package was tested with the following type checkers:
1414
* [mypy](https://github.com/python/mypy/)
15+
16+
17+
## Contributing
18+
19+
This project is very much partially complete as it is a pretty manual process.
20+
Please feel free to create PRs to help improve the stubs!
21+
The repo can be found [here](https://github.com/RISCY-Lib/pyslang-stubs)

pyproject.toml

Lines changed: 1 addition & 1 deletion
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.20250902-b2"
7+
version = "9.0.0.20250902"
88
description = "Typing stubs for the excellent pyslang library"
99
readme = "README.md"
1010
authors = [

src/pyslang-stubs/__init__.pyi

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1596,7 +1596,7 @@ class ConstantValue(metaclass=_metaclass):
15961596
def isTrue(self) -> bool: ...
15971597
def size(self) -> int: ...
15981598
@property
1599-
def value(self) -> Any: ...
1599+
def value(self) -> SVInt | float | list | dict | Null | None: ...
16001600

16011601
class Constraint(metaclass=_metaclass):
16021602
def __repr__(self) -> str: ...
@@ -5161,7 +5161,7 @@ class MatchesClauseSyntax(SyntaxNode):
51615161

51625162
class MemberAccessExpression(Expression):
51635163
@property
5164-
def member(self) -> Any: ...
5164+
def member(self) -> Symbol: ...
51655165
@property
51665166
def value(self) -> Expression: ...
51675167

@@ -5228,15 +5228,15 @@ class MethodPrototypeSymbol(Symbol, Scope):
52285228
@property
52295229
def arguments(self) -> list[FormalArgumentSymbol]: ...
52305230
@property
5231-
def firstExternImpl(self) -> Any: ...
5231+
def firstExternImpl(self) -> ExternImpl: ...
52325232
@property
52335233
def flags(self) -> MethodFlags: ...
52345234
@property
52355235
def isVirtual(self) -> bool: ...
52365236
@property
52375237
def override(self) -> Symbol: ...
52385238
@property
5239-
def returnType(self) -> Any: ...
5239+
def returnType(self) -> Type: ...
52405240
@property
52415241
def subroutine(self) -> SubroutineSymbol: ...
52425242
@property
@@ -5534,13 +5534,13 @@ class NetType(Symbol):
55345534
@staticmethod
55355535
def getSimulatedNetType(internal: NetType, external: NetType, shouldWarn: bool) -> NetType: ...
55365536
@property
5537-
def declaredType(self) -> Any: ...
5537+
def declaredType(self) -> DeclaredType: ...
55385538
@property
55395539
def isBuiltIn(self) -> bool: ...
55405540
@property
55415541
def isError(self) -> bool: ...
55425542
@property
5543-
def netKind(self) -> Any: ...
5543+
def netKind(self) -> NetKind: ...
55445544
@property
55455545
def resolutionFunction(self) -> SubroutineSymbol: ...
55465546

@@ -6079,7 +6079,7 @@ class PrimitiveSymbol(Symbol, Scope):
60796079
@property
60806080
def ports(self) -> list[PrimitivePortSymbol]: ...
60816081
@property
6082-
def primitiveKind(self) -> Any: ...
6082+
def primitiveKind(self) -> PrimitiveKind: ...
60836083
@property
60846084
def table(self) -> list[Any]: ...
60856085

@@ -6765,9 +6765,9 @@ class ScopedNameSyntax(NameSyntax):
67656765
class ScriptSession(metaclass=_metaclass):
67666766
def __init__(self) -> None: ...
67676767
def eval(self, text: str) -> ConstantValue: ...
6768-
def evalExpression(self, expr: Any) -> Any: ...
6769-
def evalStatement(self, expr: Any) -> None: ...
6770-
def getDiagnostics(self) -> Any: ...
6768+
def evalExpression(self, expr: ExpressionSyntax) -> ConstantValue: ...
6769+
def evalStatement(self, expr: StatementSyntax) -> None: ...
6770+
def getDiagnostics(self) -> Diagnostics: ...
67716771
@property
67726772
def compilation(self) -> Compilation: ...
67736773

@@ -6828,7 +6828,7 @@ class SequenceRepetition(metaclass=_metaclass):
68286828
Nonconsecutive = Kind.Nonconsecutive
68296829

68306830
@property
6831-
def kind(self) -> Any: ...
6831+
def kind(self) -> Kind: ...
68326832
@property
68336833
def range(self) -> SequenceRange: ...
68346834

@@ -7119,7 +7119,7 @@ class StandardRsCaseItemSyntax(RsCaseItemSyntax):
71197119

71207120
class Statement(metaclass=_metaclass):
71217121
def __repr__(self) -> str: ...
7122-
def eval(self, context: EvalContext) -> Any: ...
7122+
def eval(self, context: EvalContext) -> EvalResult: ...
71237123
def visit(self, f: typing.Any) -> None:
71247124
"""Visit a pyslang object with a callback function `f`.
71257125
The callback function `f` should take a single argument, which is the current node being
@@ -7138,7 +7138,7 @@ class Statement(metaclass=_metaclass):
71387138
@property
71397139
def sourceRange(self) -> SourceRange: ...
71407140
@property
7141-
def syntax(self) -> Any: ...
7141+
def syntax(self) -> StatementSyntax: ...
71427142

71437143
class StatementBlockKind(metaclass=_metaclass):
71447144
JoinAll: ClassVar[StatementBlockKind]
@@ -7315,7 +7315,7 @@ class StrongWeakAssertionExpr(AssertionExpr):
73157315
@property
73167316
def expr(self) -> AssertionExpr: ...
73177317
@property
7318-
def strength(self) -> Any: ...
7318+
def strength(self) -> Strength: ...
73197319

73207320
class StrongWeakPropertyExprSyntax(PropertyExprSyntax):
73217321
closeParen: Token

tests/test_typing.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import pytest
34

45
import pyslang
56

@@ -10,3 +11,24 @@ def test_script_session():
1011

1112
result = evaluation.eval("8'hFF")
1213
assert isinstance(result, pyslang.ConstantValue)
14+
15+
16+
@pytest.mark.parametrize("input, expected", [
17+
("8'hFF", pyslang.SVInt),
18+
("2**8", pyslang.SVInt),
19+
("2.0*3'h7", float),
20+
("null", pyslang.Null),
21+
("$someValue()", None.__class__),
22+
("string val = {\"some_str\"}; val", str),
23+
("logic [2:0]val = 3'b101; val", pyslang.SVInt),
24+
("int val[3] = {1, 2, 3}; val", list),
25+
("real val = 3.14; val", float),
26+
])
27+
def test_script_session_output(input, expected):
28+
evaluation = pyslang.ScriptSession()
29+
for stmt in input.split(";"):
30+
result = evaluation.eval(stmt + ";")
31+
print(result)
32+
value = result.value
33+
print(type(value))
34+
assert isinstance(value, expected)

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)