Skip to content

Commit

Permalink
mypy implementation for adapters in tiled (#700)
Browse files Browse the repository at this point in the history
* some more changes

* typed zarr.py

* typed tiff.py

* xarray.py typed

* some more typing added

* some more typing. still few problems in mapping.py

* more typing

* still 1 mypy problem left

* docstring skeletons added

* some more improvement

* solved some docs build problems

* few more changes

* change type_alliases.py

* some more changes

* some more changes

* update python to 3.11 in doc compilation

* fixed failing tests

* Add protocols

* change docs python to 3.10

* preliminary addressing to the comments

* some tests for protocols

* some corrections in protocols tests

* fix small bug in test_protocols.py

* try to solve EllipsisType that only exists in python 3.10

* change python version check

* some more fix

* Bump Python version of docs build.

* tests

* some more unit tests for protocols

* add accesspolicy protocol tests

* few more fixes

* python 3.8 MutableMapping problem: try to replacse with the one from typing

* try to change collections.abc.MApping with typing.Mapping if python<3.8

* small fixes for typing errors appeared in python 3.8

* one more typing fix for python 3.8

* some more fix python3.8

* Type awkward buffers dict more strictly

* Tighten typing on data_uris.

* Fix typing of partition parameter in read_partition.

* Zarr accepts array data, not dataframe/tabular.

* Remove commented unused code

* Fix typo

* Fix type of partition

* added a changelog entry

* Make python-version consistent for docs

---------

Co-authored-by: Seher Karakuzu <[email protected]>
Co-authored-by: Dan Allan <[email protected]>
  • Loading branch information
3 people authored Apr 26, 2024
1 parent 3d83726 commit 143dd22
Show file tree
Hide file tree
Showing 36 changed files with 3,049 additions and 452 deletions.
3 changes: 3 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Checklist
- [ ] Add a Changelog entry
- [ ] Add the ticket number which this PR closes to the comment section
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8]
python-version: ["3.12"]
fail-fast: false

steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8]
python-version: ["3.12"]
fail-fast: false

steps:
Expand Down
26 changes: 26 additions & 0 deletions .mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[mypy]
ignore_errors = True
ignore_missing_imports = True
disallow_untyped_defs = False
disallow_untyped_calls = False
check_untyped_defs = False
disallow_incomplete_defs = False


[mypy-tiled.adapters.*]
ignore_errors = False
ignore_missing_imports = False
check_untyped_defs = True
disallow_untyped_defs = True
disallow_incomplete_defs = True
disallow_untyped_calls = True
disallow_untyped_decorators = True

[mypy-tiled._tests.test_protocols]
ignore_errors = False
ignore_missing_imports = False
check_untyped_defs = True
disallow_untyped_defs = True
disallow_incomplete_defs = True
disallow_untyped_calls = True
disallow_untyped_decorators = True
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,9 @@ repos:
rev: 23.10.1
hooks:
- id: black

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.9.0
hooks:
- id: mypy
args: [--strict]
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Write the date in place of the "Unreleased" in the case a new version is release
- The `tiled serve ...` CLI commands now accept a `--log-config` option,
pointing to a custom uvicorn logging configuration file. An example
file was added to the repository root, `example_log_config.yml`.
- Added `tiled.adapters.protocols` which will provide possibility for user to
implement their custom adapters in a way that satisfies mypy.

### Changed

Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ dev = [
"pytest <8", # TMP pin while plugins catch up
"pytest-asyncio",
"pytest-rerunfailures",
"pytest-mock",
"sphinx !=4.1.0, !=4.1.1, !=4.1.2, !=4.2.0",
# These are dependencies of various sphinx extensions for documentation.
"ipython",
Expand Down
3 changes: 2 additions & 1 deletion tiled/_tests/test_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,8 @@ async def test_write_array_internal_direct(a, tmpdir):
)
x = await a.lookup_adapter(["x"])
await x.write(arr)
assert numpy.array_equal(await x.read(), arr)
val = await x.read()
assert numpy.array_equal(val, arr)


def test_write_array_internal_via_client(client):
Expand Down
Loading

0 comments on commit 143dd22

Please sign in to comment.