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

Add mypy and various clean up #301

Merged
merged 14 commits into from
Nov 18, 2023
Merged

Add mypy and various clean up #301

merged 14 commits into from
Nov 18, 2023

Conversation

tab-cmd
Copy link
Contributor

@tab-cmd tab-cmd commented Nov 10, 2023

Overview

Due to increased contributors and coding projects (bcifit, aiml), I did some cleanup to help with future integrations! This PR,

  • Adds mypy type checking to BciPy. This is a progressive implementation!
    • Several submodules were excluded due to needed refactors.
    • This PR will leave us at 19.42% imprecise over 11394 lines of code.
    • It resolves ~130 typing errors.
  • On average, speed up the Ubuntu builds from ~50 minutes down to ~30 minutes. Sometimes 3.9 still takes ~50min. It is the install stage, and I think WxPython is causing the main issue.
  • Adds M2 documentation and better Makefile commands for usage.

Ticket

https://www.pivotaltracker.com/story/show/177955157

Contributions

  • Made mypy as happy as I could
  • Reconfigured github actions and added the type check
  • Add documentation and cleanup as I encountered it

Test

  • make test-all
  • bcipy --fake

Documentation

  • Are documentation updates required? In-line, README, or documentation? Yes!

Changelog

  • Is the CHANGELOG.md updated with your detailed changes? Yes!

Copy link
Collaborator

@Carsonthemonkey Carsonthemonkey left a comment

Choose a reason for hiding this comment

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

Looks good to me.

Copy link
Collaborator

@lawhead lawhead left a comment

Choose a reason for hiding this comment

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

Thanks for working on this!

mypy.ini Outdated
disallow_incomplete_defs = False
check_untyped_defs = True
no_implicit_optional = True
exclude = tests|demo|gui|scripts|display.paradigm|language|signal.model|task.control|helpers.parameters
Copy link
Collaborator

Choose a reason for hiding this comment

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

Locally I get mypy errors for any psychopy imports that I have to ignore using # type: ignore. Is this something that can be added here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This configuration will silence that error! mypy, much to my dismay, doesn't allow inline exclusions, but you can disable it by file or file patterns.

bcipy/main.py Outdated
@@ -178,7 +178,7 @@ def execute_task(
def _clean_up_session(
display: visual.Window,
daq: ClientManager,
servers: List[LslDataServer] = None) -> bool:
servers: List[LslDataServer] = []) -> bool:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Probably doesn't matter too much in this context, but this should be a listing error for a dangerous default. https://stackoverflow.com/questions/9526465/best-practice-for-setting-the-default-value-of-a-parameter-thats-supposed-to-be

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I remember reading that, and I think it has bitten us before (I vaguely recall Niklas mentioning it). I am trying to remember why I preferred this here... Probably to avoid the optional!

After the multimodal merge, I need to fix some stuff, so I will revisit this before merging. Thanks for pointing out!

This test requires a valid lm_params.json file and all referenced models"""
lm = MixtureLanguageModel(response_type=ResponseType.SYMBOL, symbol_set=alphabet())
# @pytest.mark.slow
# def test_default_load(self):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Commenting out, I'm not able to get the default image...

@tab-cmd tab-cmd merged commit b03dcd2 into 2.0.0rc4 Nov 18, 2023
6 checks passed
@tab-cmd tab-cmd deleted the mypy branch November 18, 2023 00:27
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.

3 participants