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

Modernize type annotations #21

Merged
merged 2 commits into from
Aug 21, 2023
Merged

Conversation

gmgunter
Copy link
Member

Use more modern type annotations as described in PEP 585 and PEP 604. The syntax proposed in these PEPs for Python 3.9 and 3.10 can be enabled in Python>=3.7 using

from __future__ import annotations

Changes include:

  • Replace usage of (deprecated) typing.Tuple and typing.List with tuple and list
  • Replace usage of (deprecated) typing.Iterable and typing.Iterator with the corresponding classes from collections.abc
  • Use pipe (|) operator syntax to avoid usage of typing.Optional and typing.Union

I also removed some awkward custom types (IntOrInts and NDSlice) and replaced their usage in the code with their literal definitions, which have been simplified a bit by the above changes.

Use more modern type annotations as described in [PEP
585](https://peps.python.org/pep-0585) and [PEP
604](https://peps.python.org/pep-0604/). The syntax proposed in these
PEPs for Python 3.9 & 3.10 can be enabled in Python>=3.7 using

```python
from __future__ import annotations
```

* Replace usage of (deprecated) `typing.Tuple` and `typing.List` with
  `tuple` and `list`
* Replace usage of (deprecated) `typing.Iterable` and `typing.Iterator`
  with the corresponding classes from `collections.abc`
* Use pipe (`|`) operator syntax to avoid usage of `typing.Optional` and
  `typing.Union`

I also removed some awkward custom types (`IntOrInts` and `NDSlice`) and
replaced their usage in the code with their literal definitions, which
have been simplified by the above changes.
@codecov
Copy link

codecov bot commented Aug 21, 2023

Codecov Report

Merging #21 (88de595) into main (440c24b) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main      #21   +/-   ##
=======================================
  Coverage   97.62%   97.63%           
=======================================
  Files           9        9           
  Lines         759      761    +2     
=======================================
+ Hits          741      743    +2     
  Misses         18       18           
Files Changed Coverage Δ
src/tophu/io.py 96.93% <100.00%> (+0.01%) ⬆️
src/tophu/multilook.py 100.00% <100.00%> (ø)
src/tophu/multiscale.py 95.16% <100.00%> (ø)
src/tophu/tile.py 98.43% <100.00%> (-0.03%) ⬇️
src/tophu/unwrap.py 98.72% <100.00%> (+<0.01%) ⬆️
src/tophu/upsample.py 97.56% <100.00%> (ø)
src/tophu/util.py 100.00% <100.00%> (ø)

@gmgunter gmgunter merged commit f477ef6 into isce-framework:main Aug 21, 2023
6 checks passed
@gmgunter gmgunter deleted the modernize-typing branch August 21, 2023 23:50
This pull request was closed.
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.

1 participant