Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(api): apply mypy consistently across api #15821

Merged
merged 39 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
d20f46d
chore(api): apply mypy consistently across api
aaron-kulkarni Jul 29, 2024
b28c412
protocol_api_old done
aaron-kulkarni Jul 29, 2024
b15ba11
opentrons/system done
aaron-kulkarni Jul 29, 2024
3ea7e3b
failing test fixes and tempdeck changes
aaron-kulkarni Jul 30, 2024
68d1d09
random file fixes. only 598 issues remaining!
aaron-kulkarni Jul 30, 2024
f55cd28
more random file fixes. 546 left.
aaron-kulkarni Jul 30, 2024
d0f7255
Merge branch 'edge' into exec-201-strict-mypy-api
aaron-kulkarni Jul 30, 2024
7bf7cd4
format fixes, other file changes. ~500 errors to go
aaron-kulkarni Jul 30, 2024
3eead09
~450 left
aaron-kulkarni Jul 30, 2024
f4ab776
eod changes, minor
aaron-kulkarni Jul 30, 2024
ecc6433
multiple test file fixes. <400 left
aaron-kulkarni Jul 31, 2024
5d6a2bc
execute_json fixes. 275 remaining
aaron-kulkarni Jul 31, 2024
21bac8f
test_instruments file. ~215 errors left
aaron-kulkarni Jul 31, 2024
fa1ab5e
~125 left
aaron-kulkarni Aug 1, 2024
6242cf0
mostly done except for estimator. 112 left
aaron-kulkarni Aug 1, 2024
30117c0
estimator done. 35 left
aaron-kulkarni Aug 1, 2024
9940857
just transfers.py still has errors. only 10 left
aaron-kulkarni Aug 2, 2024
a10a31e
remove pdb and mypy.ini comments
aaron-kulkarni Aug 2, 2024
55320ca
various fixes/changes. no errors.
aaron-kulkarni Aug 2, 2024
130ccd5
all tests pass?
aaron-kulkarni Aug 2, 2024
8ce924f
test fix
aaron-kulkarni Aug 2, 2024
937ed73
format
aaron-kulkarni Aug 2, 2024
7febef2
done
aaron-kulkarni Aug 2, 2024
e7012b5
no code changes for max_many
sfoster1 Aug 6, 2024
5b06990
no internals for get_all_labware_definitions
sfoster1 Aug 6, 2024
4715677
protocols/labware: remove TYPE_CHECKING
sfoster1 Aug 6, 2024
031a07d
protocols/labware: no code changes
sfoster1 Aug 6, 2024
c456e9a
tests/.../test_types: remove commented code
sfoster1 Aug 6, 2024
3ac1bda
protocols/execution/dev_types: correct asdict
sfoster1 Aug 6, 2024
2fe8564
protocols/api_support/util: fix axis dict
sfoster1 Aug 7, 2024
5c785bd
protocols/advanced_control/transfers: dedupe type
sfoster1 Aug 7, 2024
7b8abc2
protocols/advanced_control/transfers: correct iter
sfoster1 Aug 7, 2024
8709c17
transfers: comments and noise
sfoster1 Aug 7, 2024
94f712d
test_wifi: path instead of str
sfoster1 Aug 7, 2024
a9ccfd3
transfers: better naming
sfoster1 Aug 7, 2024
697004e
execute_python: fix exceptions
sfoster1 Aug 7, 2024
73b0a00
protocols/labware: bad assert
sfoster1 Aug 7, 2024
8fd2f32
protocols/api_support/util: better in
sfoster1 Aug 7, 2024
048178c
Merge branch 'edge' into exec-201-strict-mypy-api
sfoster1 Aug 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 0 additions & 29 deletions api/mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,10 @@ plugins = pydantic.mypy, decoy.mypy, numpy.typing.mypy_plugin
show_error_codes = True
warn_unused_configs = True
strict = True
# TODO(mc, 2021-09-12): work through and remove these exclusions
exclude = tests/opentrons/(hardware_control/test_(?!(ot3|module_control|modules|thread_manager)).*py|hardware_control/integration/|hardware_control/emulation/|hardware_control/modules/|protocols/advanced_control/|protocols/api_support/|protocols/duration/|protocols/execution/|protocols/fixtures/|protocols/geometry/)

[pydantic-mypy]
init_forbid_extra = True
init_typed = True
warn_required_dynamic_aliases = True
warn_untyped_fields = True

# TODO(mc, 2021-09-08): fix and remove any / all of the
# overrides below whenever able
# ~115 errors
[mypy-opentrons.protocols.advanced_control.*,opentrons.protocols.api_support.*,opentrons.protocols.duration.*,opentrons.protocols.execution.dev_types,opentrons.protocols.execution.execute_json_v4,opentrons.protocols.execution.execute_python,opentrons.protocols.geometry.*,opentrons.protocols.models.*,opentrons.protocols.labware.*]
disallow_any_generics = False
disallow_untyped_defs = False
disallow_untyped_calls = False
disallow_incomplete_defs = False
no_implicit_optional = False
warn_return_any = False

# ~30 errors
[mypy-tests.opentrons.drivers.*]
disallow_untyped_defs = False
disallow_untyped_calls = False
disallow_incomplete_defs = False

[mypy-tests.opentrons.protocol_api_old.*]
disallow_untyped_defs = False
disallow_untyped_calls = False
disallow_incomplete_defs = False

# ~10 errors
[mypy-tests.opentrons.system.*]
disallow_untyped_defs = False
disallow_untyped_calls = False
disallow_incomplete_defs = False
5 changes: 3 additions & 2 deletions api/src/opentrons/hardware_control/backends/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,21 @@ class Controller:
"""

@classmethod
async def build(cls, config: RobotConfig) -> Controller:
async def build(cls, config: Optional[RobotConfig]) -> Controller:
"""Build a Controller instance.

Use this factory method rather than the initializer to handle proper
GPIO initialization.

:param config: A loaded robot config.
"""

gpio = build_gpio_chardev("gpiochip0")
gpio.config_by_board_rev()
await gpio.setup()
return cls(config, gpio)

def __init__(self, config: RobotConfig, gpio: GPIODriverLike):
def __init__(self, config: Optional[RobotConfig], gpio: GPIODriverLike):
"""Build a Controller instance.

Always prefer using :py:meth:`.build` to create an instance of this class. For
Expand Down
6 changes: 3 additions & 3 deletions api/src/opentrons/hardware_control/modules/magdeck.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import asyncio
import logging
from typing import Mapping, Optional
from typing import Dict, Optional
from opentrons.drivers.mag_deck import (
SimulatingDriver,
MagDeckDriver,
Expand Down Expand Up @@ -81,7 +81,7 @@ def __init__(
execution_manager: ExecutionManager,
hw_control_loop: asyncio.AbstractEventLoop,
driver: AbstractMagDeckDriver,
device_info: Mapping[str, str],
device_info: Dict[str, str],
) -> None:
"""Constructor"""
super().__init__(
Expand Down Expand Up @@ -162,7 +162,7 @@ def current_height(self) -> float:
return self._current_height

@property
def device_info(self) -> Mapping[str, str]:
def device_info(self) -> Dict[str, str]:
"""

Returns: a dict
Expand Down
8 changes: 4 additions & 4 deletions api/src/opentrons/hardware_control/modules/tempdeck.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import asyncio
import logging
from typing import Mapping, Optional
from typing import Dict, Optional

from opentrons.hardware_control.modules.types import TemperatureStatus
from opentrons.hardware_control.poller import Reader, Poller
Expand All @@ -26,7 +26,7 @@
class TempDeck(mod_abc.AbstractModule):
"""Hardware control interface for an attached Temperature Module."""

MODULE_TYPE = types.ModuleType.TEMPERATURE
MODULE_TYPE = types.ModuleType["TEMPERATURE"]
FIRST_GEN2_REVISION = 20

@classmethod
Expand Down Expand Up @@ -94,7 +94,7 @@ def __init__(
driver: AbstractTempDeckDriver,
reader: TempDeckReader,
poller: Poller,
device_info: Mapping[str, str],
device_info: Dict[str, str],
hw_control_loop: asyncio.AbstractEventLoop,
) -> None:
"""Constructor"""
Expand Down Expand Up @@ -182,7 +182,7 @@ async def deactivate(self, must_be_running: bool = True) -> None:
await self._reader.read()

@property
def device_info(self) -> Mapping[str, str]:
def device_info(self) -> Dict[str, str]:
return self._device_info

@property
Expand Down
7 changes: 1 addition & 6 deletions api/src/opentrons/protocol_api/instrument_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,7 @@
from . import labware, validation


AdvancedLiquidHandling = Union[
labware.Well,
types.Location,
Sequence[Union[labware.Well, types.Location]],
Sequence[Sequence[labware.Well]],
]
AdvancedLiquidHandling = transfers.AdvancedLiquidHandling

_DEFAULT_ASPIRATE_CLEARANCE = 1.0
_DEFAULT_DISPENSE_CLEARANCE = 1.0
Expand Down
8 changes: 3 additions & 5 deletions api/src/opentrons/protocols/advanced_control/mix.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import typing
from typing import Any, Dict, Tuple

from opentrons.protocols.advanced_control.transfers import MixStrategy, Mix


def mix_from_kwargs(
top_kwargs: typing.Dict[str, typing.Any]
) -> typing.Tuple[MixStrategy, Mix]:
def mix_from_kwargs(top_kwargs: Dict[str, Any]) -> Tuple[MixStrategy, Mix]:
"""A utility function to determine mix strategy from key word arguments
to InstrumentContext.mix"""

def _mix_requested(kwargs, opt):
def _mix_requested(kwargs: Dict[str, Any], opt: str) -> bool:
"""
Helper for determining mix options from :py:meth:`transfer` kwargs
Mixes can be ignored in kwargs by either
Expand Down
Loading
Loading