Skip to content

Commit

Permalink
Made ruff and mypy complient, moved 'examples' into src/pandablocks
Browse files Browse the repository at this point in the history
  • Loading branch information
evalott100 committed Oct 17, 2023
1 parent 8c65af3 commit 5a3ce72
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 31 deletions.
14 changes: 7 additions & 7 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
("py:class", "'object'"),
("py:class", "'id'"),
("py:class", "typing_extensions.Literal"),
("py:func", "int")
("py:func", "int"),
]

# Both the class’ and the __init__ method’s docstring are concatenated and
Expand Down Expand Up @@ -103,14 +103,14 @@

# This means you can link things like `str` and `asyncio` to the relevant
# docs in the python documentation.
intersphinx_mapping = dict(
python=("https://docs.python.org/3/", None),
numpy=("https://numpy.org/doc/stable/", None),
h5py=("https://docs.h5py.org/en/stable/", None),
)
intersphinx_mapping = {
"python": ("https://docs.python.org/3/", None),
"numpy": ("https://numpy.org/doc/stable/", None),
"h5py": ("https://docs.h5py.org/en/stable/", None),
}

# A dictionary of graphviz graph attributes for inheritance diagrams.
inheritance_graph_attrs = dict(rankdir="TB")
inheritance_graph_attrs = {"rankdir": "TB"}

# Common links that should be available on every page
rst_epilog = """
Expand Down
2 changes: 1 addition & 1 deletion src/pandablocks/_version_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,4 @@ def make_release_tree(self, base_dir, files):
for pkg in self.distribution.packages:
make_version_static(base_dir, pkg)

return dict(build_py=BuildPy, sdist=Sdist)
return {"build_py": BuildPy, "sdist": Sdist}

Check warning on line 97 in src/pandablocks/_version_git.py

View check run for this annotation

Codecov / codecov/patch

src/pandablocks/_version_git.py#L97

Added line #L97 was not covered by tests
13 changes: 0 additions & 13 deletions src/pandablocks/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,6 @@ class GetFieldInfo(Command[Dict[str, FieldInfo]]):
] = field(init=False, repr=False, default_factory=dict)

def __post_init__(self):

# Map a (type, subtype) to a method that returns the appropriate
# subclasss of FieldInfo, and a list of all the Commands to request.
# Note that fields that do not have additional attributes are not listed.
Expand Down Expand Up @@ -472,7 +471,6 @@ def _get_desc(self, field_name: str) -> GetLine:
def _uint(
self, field_name: str, field_type: str, field_subtype: Optional[str]
) -> _FieldGeneratorType:

desc, maximum = yield from _execute_commands(
self._get_desc(field_name),
GetLine(f"{self.block}1.{field_name}.MAX"),
Expand All @@ -484,7 +482,6 @@ def _uint(
def _scalar(
self, field_name: str, field_type: str, field_subtype: Optional[str]
) -> _FieldGeneratorType:

desc, units, scale, offset = yield from _execute_commands(
self._get_desc(field_name),
GetLine(f"{self.block}.{field_name}.UNITS"),
Expand All @@ -501,7 +498,6 @@ def _scalar(
def _subtype_time(
self, field_name: str, field_type: str, field_subtype: Optional[str]
) -> _FieldGeneratorType:

desc, units_labels = yield from _execute_commands(
self._get_desc(field_name),
GetMultiline(f"*ENUMS.{self.block}.{field_name}.UNITS"),
Expand All @@ -514,7 +510,6 @@ def _subtype_time(
def _enum(
self, field_name: str, field_type: str, field_subtype: Optional[str]
) -> _FieldGeneratorType:

desc, labels = yield from _execute_commands(
self._get_desc(field_name),
GetMultiline(f"*ENUMS.{self.block}.{field_name}"),
Expand All @@ -527,7 +522,6 @@ def _enum(
def _time(
self, field_name: str, field_type: str, field_subtype: Optional[str]
) -> _FieldGeneratorType:

desc, units, min = yield from _execute_commands(
self._get_desc(field_name),
GetMultiline(f"*ENUMS.{self.block}.{field_name}.UNITS"),
Expand All @@ -541,7 +535,6 @@ def _time(
def _bit_out(
self, field_name: str, field_type: str, field_subtype: Optional[str]
) -> _FieldGeneratorType:

desc, capture_word, offset = yield from _execute_commands(
self._get_desc(field_name),
GetLine(f"{self.block}1.{field_name}.CAPTURE_WORD"),
Expand All @@ -557,7 +550,6 @@ def _bit_out(
def _bit_mux(
self, field_name: str, field_type: str, field_subtype: Optional[str]
) -> _FieldGeneratorType:

desc, max_delay, labels = yield from _execute_commands(
self._get_desc(field_name),
GetLine(f"{self.block}1.{field_name}.MAX_DELAY"),
Expand All @@ -573,7 +565,6 @@ def _bit_mux(
def _pos_mux(
self, field_name: str, field_type: str, field_subtype: Optional[str]
) -> _FieldGeneratorType:

desc, labels = yield from _execute_commands(
self._get_desc(field_name),
GetMultiline(f"*ENUMS.{self.block}.{field_name}"),
Expand All @@ -585,7 +576,6 @@ def _pos_mux(
def _table(
self, field_name: str, field_type: str, field_subtype: Optional[str]
) -> _FieldGeneratorType:

# Ignore the ROW_WORDS attribute as it's new and won't be present on all PandAs,
# and there's no easy way to try it and catch an error while also running other
# Get commands at the same time
Expand Down Expand Up @@ -655,7 +645,6 @@ def _table(
def _pos_out(
self, field_name: str, field_type: str, field_subtype: Optional[str]
) -> _FieldGeneratorType:

desc, capture_labels = yield from _execute_commands(
self._get_desc(field_name),
GetMultiline(f"*ENUMS.{self.block}.{field_name}.CAPTURE"),
Expand All @@ -667,7 +656,6 @@ def _pos_out(
def _ext_out(
self, field_name: str, field_type: str, field_subtype: Optional[str]
) -> _FieldGeneratorType:

desc, capture_labels = yield from _execute_commands(
self._get_desc(field_name),
GetMultiline(f"*ENUMS.{self.block}.{field_name}.CAPTURE"),
Expand Down Expand Up @@ -845,7 +833,6 @@ def execute(self) -> ExchangeGenerator[Changes]:
multivalue_get_commands: List[Tuple[str, GetMultiline]] = []
for line in ex.multiline:
if line[-1] == "<":

if self.get_multiline:
field = line[0:-1]
multivalue_get_commands.append((field, GetMultiline(field)))
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
async def introspect():
# Create a client and connect the control and data ports
async with AsyncioClient(sys.argv[1]) as client:

# Get the list of all blocks in the PandA
block_info = await client.send(GetBlockInfo())
# Find and print all fields for each block
Expand Down
File renamed without changes.
1 change: 0 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@ def fast_dump_expected():


class DummyServer:

# Flag for useful debug output when writing tests
# for diagnosing mismatching sent data.
debug = False
Expand Down
4 changes: 3 additions & 1 deletion tests/test_asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ async def test_asyncio_bad_put_raises(dummy_server_async):
async def test_asyncio_data(
dummy_server_async, fast_dump, fast_dump_expected, disarmed, flush_period
):
print(disarmed)
print(flush_period)
if not disarmed:
# simulate getting the data without the END marker as if arm was not pressed
fast_dump = map(lambda x: x.split(b"END")[0], fast_dump)
fast_dump = (x.split(b"END")[0] for x in fast_dump)
fast_dump_expected = list(fast_dump_expected)[:-1]
dummy_server_async.data = fast_dump
events = []
Expand Down
14 changes: 7 additions & 7 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,13 @@ def table_data_1() -> List[str]:

@pytest.fixture
def table_2_np_arrays() -> Dict[str, UnpackedArray]:
table: Dict[str, UnpackedArray] = dict(
REPEATS=np.array([1, 0], dtype=np.uint32),
TRIGGER=["Immediate", "Immediate"],
POSITION=np.array([-20, 2**31 - 1], dtype=np.int32),
TIME1=np.array([12, 2**32 - 1], dtype=np.uint32),
TIME2=np.array([32, 1], dtype=np.uint32),
)
table: Dict[str, UnpackedArray] = {
"REPEATS": np.array([1, 0], dtype=np.uint32),
"TRIGGER": ["Immediate", "Immediate"],
"POSITION": np.array([-20, 2**31 - 1], dtype=np.int32),
"TIME1": np.array([12, 2**32 - 1], dtype=np.uint32),
"TIME2": np.array([32, 1], dtype=np.uint32),
}

table["OUTA1"] = np.array([0, 1], dtype=np.uint8)
table["OUTA2"] = np.array([1, 0], dtype=np.uint8)
Expand Down

0 comments on commit 5a3ce72

Please sign in to comment.