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

refactor: Use string literal types of generic builtins for type checking #1942

Merged
merged 3 commits into from
Aug 12, 2022

Conversation

matthewfeickert
Copy link
Member

@matthewfeickert matthewfeickert commented Aug 12, 2022

Description

Resolves #1941

Thanks @henryiii for the nudge on this.

Checklist Before Requesting Reviewer

  • Tests are passing
  • "WIP" removed from the title of the pull request
  • Selected an Assignee for the PR to be responsible for the log summary

Before Merging

For the PR Assignees:

  • Summarize commit messages into a comprehensive review of the PR
* Use string literal types of generic builtins for type checking until Python
  3.8 support is dropped (so pyhf is Python 3.9+ only) to avoid having to
  check for `if typing.TYPE_CHECKING`.
   - c.f. https://mypy.readthedocs.io/en/stable/runtime_troubles.html#string-literal-types
   - c.f. https://mypy.readthedocs.io/en/stable/builtin_types.html#generic-types
   - c.f. https://mypy.readthedocs.io/en/stable/runtime_troubles.html#generic-builtins
   - c.f. https://peps.python.org/pep-0585/
* Remove .coveragerc as no longer needed.
   - Reverts PR #1937

@matthewfeickert matthewfeickert added refactor A code change that neither fixes a bug nor adds a feature revert Reverts a previous commit labels Aug 12, 2022
@matthewfeickert matthewfeickert self-assigned this Aug 12, 2022
@matthewfeickert
Copy link
Member Author

matthewfeickert commented Aug 12, 2022

I didn't do a good job of describing the details in the PR body, so we should make this more clear before merging and rename the PR to something more correct.

@matthewfeickert matthewfeickert added the type checking Related to types and type checking label Aug 12, 2022
@codecov
Copy link

codecov bot commented Aug 12, 2022

Codecov Report

Merging #1942 (9b52d3d) into master (6f8d87e) will not change coverage.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #1942   +/-   ##
=======================================
  Coverage   98.26%   98.26%           
=======================================
  Files          69       69           
  Lines        4439     4439           
  Branches      748      748           
=======================================
  Hits         4362     4362           
  Misses         45       45           
  Partials       32       32           
Flag Coverage Δ
contrib 25.81% <0.00%> (ø)
doctest 61.02% <100.00%> (ø)
unittests-3.10 96.14% <100.00%> (ø)
unittests-3.7 96.13% <100.00%> (ø)
unittests-3.8 96.17% <100.00%> (ø)
unittests-3.9 96.19% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/pyhf/typing.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@matthewfeickert matthewfeickert changed the title refactor: Use string form of type checking refactor: Use string form of generic builtins for type checking Aug 12, 2022
* Use the string form of type checking until Python 3.7 is dropped to
avoid having to check for `if typing.TYPE_CHECKING`.
* Revert PR 1937
@matthewfeickert matthewfeickert force-pushed the refactor/remove-type-checking-check branch from 0352d0d to 9b52d3d Compare August 12, 2022 21:26
@matthewfeickert matthewfeickert marked this pull request as ready for review August 12, 2022 21:26
@matthewfeickert matthewfeickert changed the title refactor: Use string form of generic builtins for type checking refactor: Use string literal types of generic builtins for type checking Aug 12, 2022
@matthewfeickert matthewfeickert merged commit a618640 into master Aug 12, 2022
@matthewfeickert matthewfeickert deleted the refactor/remove-type-checking-check branch August 12, 2022 22:33
matthewfeickert pushed a commit that referenced this pull request Aug 26, 2022
* Add typehints to the NumPy backend.
* Add .coveragerc file with configuration to ignore pyhf/typing.py.
  - ref: https://coverage.readthedocs.io/en/6.4.3/excluding.html#advanced-exclusion
  - Reverts part of PR #1942.
* Ignore pyhf/typing.py in Codecov.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor A code change that neither fixes a bug nor adds a feature revert Reverts a previous commit type checking Related to types and type checking
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use string form for type checking until Python 3.7 dropped
2 participants