Skip to content

Commit 6b65efd

Browse files
authored
Merge pull request #87 from monkeyman192/small_typing_changes
small typing fixes
2 parents 713a05c + fbd9e6c commit 6b65efd

File tree

5 files changed

+27
-7
lines changed

5 files changed

+27
-7
lines changed

docs/docs/change_log.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Change Log
22
==========
33

4-
Current (0.1.17.dev)
4+
Current (0.2.0.dev)
55
--------------------
66

77
- Further improved partial structs to allow nesting references to themselves as a type (must be "indirect", ie. the type of a pointer, or dynamic array for example).

pymhf/extensions/ctypes.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ class c_enum32(ctypes.c_int32, Generic[IE]):
1616

1717
_enum_type: Type[IE]
1818

19+
@classmethod
20+
def _members(cls):
21+
return list(cls._enum_type.__members__.keys())
22+
1923
@property
2024
def _enum_value(self) -> IE:
2125
return self._enum_type(self.value)

pymhf/gui/gui.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class WidgetType(Enum):
3737

3838
class Widgets(TypedDict):
3939
buttons: dict[str, Union[int, str]]
40-
comboboxes: dict[str, Union[int, str]]
40+
comboboxes: dict[str, list[tuple[Union[int, str], WidgetType]]]
4141
variables: dict[str, list[tuple[Union[int, str], WidgetType]]]
4242

4343

tests/unit/test_c_enums.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from enum import IntEnum
2+
3+
import pytest
4+
5+
from pymhf.extensions.ctypes import c_enum32
6+
7+
8+
def test_invalid_c_enum32_cases():
9+
with pytest.raises(TypeError):
10+
c_enum32[22]
11+
12+
13+
def test_c_enum_members():
14+
class Alphabet(IntEnum):
15+
A = 0
16+
B = 1
17+
C = 2
18+
D = 3
19+
E = 4
20+
21+
assert c_enum32[Alphabet]._members() == ["A", "B", "C", "D", "E"]

tests/unit/test_partial_structs.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -403,11 +403,6 @@ class Test4(ctypes.Structure):
403403
a: Annotated[ctypes.c_int32, "hi"]
404404

405405

406-
def test_invalid_c_enum32_cases():
407-
with pytest.raises(TypeError):
408-
c_enum32[22]
409-
410-
411406
T = TypeVar("T", bound=Union[ctypes._SimpleCData, ctypes.Structure])
412407

413408

0 commit comments

Comments
 (0)