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

Mypy Errors Triggered in Local Development #58

Open
wants to merge 4 commits into
base: release/0.10.0
Choose a base branch
from

Conversation

KamenDimitrov97
Copy link
Contributor

🐛 Bug Fix

Description

Mypy is raising unexpected generic errors for new developers joining the project, despite being configured to ignore them. These errors are only affecting local development and do not appear in the CI pipeline.

Root Cause:

Different Mypy configurations in the pre-commit hooks and the CI setup are causing the errors.

Testing:

Modified different files to see which errors appeared in the pre-commit checks.

Checklist

  • I have included a clear description of the bug.

Who can review?

Ellery, Phil, Ed

@KamenDimitrov97 KamenDimitrov97 self-assigned this Oct 11, 2024
@KamenDimitrov97 KamenDimitrov97 changed the base branch from main to release/0.10.0 October 11, 2024 10:17
Copy link

@edufnt edufnt left a comment

Choose a reason for hiding this comment

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

I have added a minimal change:

(dew) esc@esc-flax:~/GithubRepos/Dewret$ git status
On branch fix/mypy-hook-errors-for-new-devs
Your branch is up to date with 'origin/fix/mypy-hook-errors-for-new-devs'.

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        modified:   tests/test_annotations.py

(dew) esc@esc-flax:~/GithubRepos/Dewret$ git diff HEAD
diff --git a/tests/test_annotations.py b/tests/test_annotations.py
index f62479d..d1f5123 100644
--- a/tests/test_annotations.py
+++ b/tests/test_annotations.py
@@ -56,6 +56,7 @@ def test_can_analyze_annotations() -> None:
     assert analyser.argument_has("arg3", AtRender, exhaustive=True) is False
     assert analyser.argument_has("ARG2", AtRender, exhaustive=True) is False
     assert analyser.argument_has("arg2", AtRender, exhaustive=True) is True
+    assert analyser.argument_has("arg2", AtRender, exhaustive=False) is True
     assert (
         analyser.argument_has("arg4", AtRender, exhaustive=True) is False
     )  # Not a global/argument
@@ -67,6 +68,7 @@ def test_can_analyze_annotations() -> None:
     assert analyser.argument_has("arg7", AtRender, exhaustive=True) is False
     assert analyser.argument_has("ARG2", AtRender, exhaustive=True) is False
     assert analyser.argument_has("arg6", AtRender, exhaustive=True) is True
+    assert analyser.argument_has("arg6", AtRender, exhaustive=False) is True
     assert (
         analyser.argument_has("arg8", AtRender, exhaustive=True) is False
     )  # Not a global/argument
(dew) esc@esc-flax:~/GithubRepos/Dewret$

and I am still seeing this:

(dew) esc@esc-flax:~/GithubRepos/Dewret$ git commit
ruff.....................................................................Passed
ruff-format..............................................................Passed
mypy.....................................................................Failed
- hook id: mypy
- exit code: 1

tests/_lib/other.py:1: error: Cannot find implementation or library stub for module named "dewret.annotations"  [import-not-found]
tests/_lib/extra.py:1: error: Cannot find implementation or library stub for module named "dewret.tasks"  [import-not-found]
tests/_lib/extra.py:9: error: Untyped decorator makes function "try_nothing" untyped  [misc]
tests/_lib/extra.py:13: error: Returning Any from function declared to return "int"  [no-any-return]
tests/_lib/extra.py:14: error: Returning Any from function declared to return "int"  [no-any-return]
tests/_lib/extra.py:16: error: Untyped decorator makes function "increase" untyped  [misc]
tests/_lib/extra.py:22: error: Untyped decorator makes function "increment" untyped  [misc]
tests/_lib/extra.py:28: error: Untyped decorator makes function "double" untyped  [misc]
tests/_lib/extra.py:34: error: Untyped decorator makes function "mod10" untyped  [misc]
tests/_lib/extra.py:40: error: Untyped decorator makes function "sum" untyped  [misc]
tests/_lib/extra.py:46: error: Untyped decorator makes function "pi" untyped  [misc]
tests/_lib/extra.py:54: error: Untyped decorator makes function "triple_and_one" untyped  [misc]
tests/_lib/extra.py:57: error: Returning Any from function declared to return "int | float"  [no-any-return]
tests/_lib/extra.py:60: error: Untyped decorator makes function "tuple_float_return" untyped  [misc]
tests/_lib/extra.py:65: error: Untyped decorator makes function "reverse_list" untyped  [misc]
tests/_lib/extra.py:69: error: Untyped decorator makes function "max_list" untyped  [misc]
tests/test_annotations.py:6: error: Cannot find implementation or library stub for module named "dewret.tasks"  [import-not-found]
tests/test_annotations.py:7: error: Cannot find implementation or library stub for module named "dewret.renderers.cwl"  [import-not-found]
tests/test_annotations.py:7: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
tests/test_annotations.py:8: error: Cannot find implementation or library stub for module named "dewret.annotations"  [import-not-found]
tests/test_annotations.py:9: error: Cannot find implementation or library stub for module named "dewret.core"  [import-not-found]
tests/test_annotations.py:24: error: Returning Any from function declared to return "float"  [no-any-return]
tests/test_annotations.py:31: error: Returning Any from function declared to return "float"  [no-any-return]
tests/test_annotations.py:34: error: Untyped decorator makes function "to_int_bad" untyped  [misc]
tests/test_annotations.py:37: error: Returning Any from function declared to return "int | float"  [no-any-return]
tests/test_annotations.py:40: error: Untyped decorator makes function "to_int" untyped  [misc]
tests/test_annotations.py:43: error: Returning Any from function declared to return "int | float"  [no-any-return]
tests/test_annotations.py:176: error: Untyped decorator makes function "loop_over_lists" untyped  [misc]
Found 27 errors in 3 files (checked 1 source file)

@eduardoofthehour
Copy link

I am still seeing this after creating a new environment and building from scratch, I have created a branch with the build script in feat/build-script. To test it:

  • I checkout this branch.
  • Merge feat/build-script into it
  • Call the build script . ./create_env_and_build.sh test-env
  • add the following line after line 58 in test_annotations.py
    assert analyser.argument_has("arg2", AtRender, exhaustive=False) is True
  • try to commit

Copy link
Contributor

@elleryames elleryames left a comment

Choose a reason for hiding this comment

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

Thanks @KamenDimitrov97 !

src/dewret/core.py Show resolved Hide resolved
Copy link
Contributor

@philtweir philtweir left a comment

Choose a reason for hiding this comment

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

Thanks @KamenDimitrov97 !

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.

5 participants