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

Conversation

aaron-kulkarni
Copy link
Contributor

@aaron-kulkarni aaron-kulkarni commented Jul 29, 2024

Overview

At present, typechecking is not applied fully and consistently across the API directory. This PR removes exceptions to mypy checking rules and makes sure that all mypy typechecking tests pass.

EXEC-201 EXEC-202

Test Plan and Hands on Testing

Remove all exceptions from api/mypy.ini and run make -C api lint from the home directory and make sure all the tests pass.

Changelog

Review requests

Lots of file changes in this one. Most changes in most files are just monotonous -> None function return type annotations(or something similar). For reviewers, I would focus on the following files:

protocols/labware.py: My edits to _check_for_subdirectories seem strange. I'm not confident in the new things I imported to get that type annotation to work.

test_transfers.py: There are dozens of conversions between Location, Well, and Location | Well. What should be done about these? If one function has a Well and wants to call a function that takes in a Location, how should I convert it?

Risk assessment

Low.

@aaron-kulkarni aaron-kulkarni marked this pull request as ready for review August 2, 2024 13:22
@aaron-kulkarni aaron-kulkarni requested a review from a team as a code owner August 2, 2024 13:22
Copy link
Member

@sfoster1 sfoster1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going from Well to Location is done by doing well.top() or well.bottom() or something. In general though, I wouldn't worry too much about it; just getting the warnings removed is good enough, and making the typing elegant can happen in a followup pass.

The things to worry about are actual non-typechecking code changes to production software. That's what needs a second look, as in the API transfers code, for instance.

api/src/opentrons/protocols/labware.py Outdated Show resolved Hide resolved
hw_api_cntrlr = await API.build_hardware_controller(
loop=asyncio.get_running_loop(),
feature_flags=HardwareFeatureFlags.build_from_ff(),
firmware=_find_smoothie_file(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should Be NONE since this isn't running on an actual robot

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Talked about in person - made a different change

@aaron-kulkarni aaron-kulkarni requested a review from sfoster1 August 2, 2024 18:26
@aaron-kulkarni aaron-kulkarni changed the base branch from edge to chore_release-8.0.0 August 2, 2024 20:44
Copy link
Member

@sfoster1 sfoster1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed this, fixed up some little changes and some noise, very happy with it

@sfoster1 sfoster1 changed the base branch from chore_release-8.0.0 to edge August 7, 2024 14:20
Copy link
Contributor

@SyntaxColoring SyntaxColoring left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This mostly looks good to me, but here's a few things that look questionable.

api/tests/opentrons/system/test_wifi.py Outdated Show resolved Hide resolved
api/tests/opentrons/system/test_wifi.py Outdated Show resolved Hide resolved
api/src/opentrons/protocols/advanced_control/transfers.py Outdated Show resolved Hide resolved
api/src/opentrons/protocols/api_support/util.py Outdated Show resolved Hide resolved
api/src/opentrons/protocols/execution/execute_python.py Outdated Show resolved Hide resolved
api/src/opentrons/protocols/labware.py Outdated Show resolved Hide resolved
Copy link
Contributor

@SyntaxColoring SyntaxColoring left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hallelujah.

@sfoster1
Copy link
Member

sfoster1 commented Aug 7, 2024

The failing tests are because fe6252c needs to be merged into edge as well as release

@sfoster1 sfoster1 merged commit 606c58d into edge Aug 7, 2024
43 checks passed
@sfoster1 sfoster1 deleted the exec-201-strict-mypy-api branch August 7, 2024 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants