Skip to content

Fix type validators to work with future versions of type hints#146

Merged
callumforrester merged 2 commits intomainfrom
anno-fix
Apr 24, 2023
Merged

Fix type validators to work with future versions of type hints#146
callumforrester merged 2 commits intomainfrom
anno-fix

Conversation

@callumforrester
Copy link
Copy Markdown
Contributor

Several tests broke when using

from __future__ import annotations

Because in the future type annotations will be more lazily. We must use a specific function, typing.get_type_hints to properly evaluate them.
This is annoying as we still need to use signature().parameters to get the default values, but I could not find a better way.

This PR adds the future import to the tests and invokes the requires function.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 24, 2023

Codecov Report

Merging #146 (13089ba) into main (90b4710) will increase coverage by 0.07%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #146      +/-   ##
==========================================
+ Coverage   74.52%   74.59%   +0.07%     
==========================================
  Files          37       37              
  Lines        1048     1051       +3     
==========================================
+ Hits          781      784       +3     
  Misses        267      267              
Impacted Files Coverage Δ
src/blueapi/utils/base_model.py 100.00% <100.00%> (ø)
src/blueapi/utils/serialization.py 87.50% <100.00%> (ø)
src/blueapi/utils/type_validator.py 88.88% <100.00%> (+0.19%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@callumforrester callumforrester merged commit fe35a25 into main Apr 24, 2023
@callumforrester callumforrester deleted the anno-fix branch April 24, 2023 15:13
keithralphs pushed a commit that referenced this pull request Apr 28, 2023
* Add future annotations to type validator test and fix issues to do with lazy evaluation

* Handle case of type annotation not being present
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