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

Solve mypy errors. #780

Merged
merged 8 commits into from
Nov 20, 2024
Merged

Solve mypy errors. #780

merged 8 commits into from
Nov 20, 2024

Conversation

knutnergaard
Copy link
Contributor

@knutnergaard knutnergaard commented Nov 19, 2024

Continuation of #776.

Remaining errors to be collected in #775:

glyph.py:85: error: Signature of "_reprContents" incompatible with supertype "BaseObject"  [override]
glyph.py:85: note:      Superclass:
glyph.py:85: note:          @classmethod
glyph.py:85: note:          def _reprContents(cls) -> List[str]
glyph.py:85: note:      Subclass:
glyph.py:85: note:          def _reprContents(self) -> List[str]
glyph.py:2790: error: Signature of "isCompatible" incompatible with supertype "InterpolationMixin"  [override]
glyph.py:2790: note:      Superclass:
glyph.py:2790: note:          def isCompatible(self, other: Any, cls: Type[Any]) -> Tuple[bool, Any]
glyph.py:2790: note:      Subclass:
glyph.py:2790: note:          def isCompatible(self, other: BaseGlyph) -> Tuple[bool, str]

@knutnergaard
Copy link
Contributor Author

knutnergaard commented Nov 19, 2024

@benkiel Not sure what's wrong here.
Are the margin setters value type supposed to be Optional[IntFloatType], same as the margin getters return type?

@benkiel
Copy link
Member

benkiel commented Nov 19, 2024

@knutnergaard no, setters should not allow None, getters may return that: a glyph with no outlines will not have margins

@knutnergaard
Copy link
Contributor Author

knutnergaard commented Nov 19, 2024

@benkiel OK, then is it possible that the tests for the margins properties should be updated?

Since e.g., normalizeGlyphBottomMargin allows -> Optional[IntFloatType] (i.e., int, float and None), mypy is complaining that set_base_bottomMargin potentially passes None to set_bottomMargin, which only allows IntFloatType. Unfortunately, when attempting to eliminate None before the call to set_bottomMargin, the test fails.

Hopefully that made sense.

@knutnergaard
Copy link
Contributor Author

Solved.

@benkiel
Copy link
Member

benkiel commented Nov 20, 2024

@knutnergaard I'm trying to work out why this change made things fail initially...

@benkiel
Copy link
Member

benkiel commented Nov 20, 2024

Figured it out: type error was thrown in the math part, but I see where mypy got grumpy with that. Change has the nice effect of a better error message!

@benkiel benkiel merged commit b38e4e6 into robotools:v1 Nov 20, 2024
10 checks passed
@knutnergaard knutnergaard deleted the annotation branch November 22, 2024 16:25
@knutnergaard knutnergaard restored the annotation branch November 22, 2024 16:25
@knutnergaard knutnergaard deleted the annotation branch November 22, 2024 16:26
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.

2 participants