This repository has been archived by the owner on Oct 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Block names can have numbers and underscores in - Type hints seem to work better on the class, not instance - Added demo - Added type hints function which doesn't look through parent classes
- Loading branch information
1 parent
72b3517
commit 1f1abce
Showing
4 changed files
with
59 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from bluesky import RunEngine | ||
|
||
# these three lines just let you use await statements | ||
# #in ipython terminal with the Run Engine event loop. | ||
from IPython import get_ipython | ||
from ophyd.v2.core import DeviceCollector | ||
|
||
from ophyd_epics_devices.panda import PandA | ||
|
||
get_ipython().run_line_magic("autoawait", "call_in_bluesky_event_loop") | ||
RE = RunEngine() | ||
|
||
with DeviceCollector(): | ||
my_panda = PandA("TS-PANDA") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from typing import get_type_hints | ||
|
||
|
||
# Use with types, not instances | ||
def get_type_hints_no_inheritance(cls): | ||
cls_hints = get_type_hints(cls) | ||
|
||
for base_cls in cls.__bases__: | ||
base_hints = get_type_hints(base_cls) | ||
for base_hint_names in base_hints.keys(): | ||
if base_hint_names in cls_hints: | ||
del cls_hints[base_hint_names] | ||
return cls_hints |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from typing import get_type_hints | ||
|
||
from ophyd_epics_devices.utils import get_type_hints_no_inheritance | ||
|
||
|
||
def test_get_type_hints_no_inheritance(): | ||
class BaseClass: | ||
base_integer: int | ||
base_string: str | ||
|
||
class SubClass(BaseClass): | ||
integer: int | ||
string: str | ||
|
||
assert get_type_hints(SubClass) == { | ||
"base_integer": int, | ||
"base_string": str, | ||
"integer": int, | ||
"string": str, | ||
} | ||
assert get_type_hints_no_inheritance(SubClass) == {"integer": int, "string": str} |