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

mypy: analyze types in all possible libraries #658

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rominf
Copy link
Contributor

@rominf rominf commented Aug 30, 2023

Preparation for #646

  • Remove ignore_missing_imports = true from mypy configuration.
  • Run mypy in the same environment instead of separate to check types
    in dependencies like fastapi.
  • Move mypy dependencies from pre-commit configuration to setup.cfg.
  • Update mypy dependencies there.
  • Move rq from environment.yml to setup.cfg: conda-forge version:
    1.9.0, pypi version : 1.15.1 (two years difference; types were added).
  • Add libraries with missing types to ignore list in mypy
    configuration.
  • Add pydantic mypy plugin.
  • Allow running mypy without explicit paths.
  • Update GitHub Actions.
  • Temporarily add ignore annotation-unchecked to make mypy pass.
  • Fix new mypy issues:
    • Use https://github.com/hauntsaninja/no_implicit_optional to make
      Optional explicit.
    • If there is no default, the first pydantic.Field argument should
      be omitted (None means that the default argument is None).
    • Refactor _run_migrations. There were two different paths: one for
      normal execution and another one for testing. Simplify arguments and
      the function code, and introduce a new mock run_migrations.
    • To preserve compatibility, introduce ChannelWithOptionalName for
      the /channels patch method. Note that the solution is a bit dirty
      (I had to use type: ignore[assignment]) to minimize the number of
      models and the diff.
    • Trivial errors.

@codecov-commenter
Copy link

codecov-commenter commented Aug 30, 2023

Codecov Report

Patch coverage: 95.65% and project coverage change: -0.03% ⚠️

Comparison is base (7501519) 83.64% compared to head (deda79d) 83.61%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #658      +/-   ##
==========================================
- Coverage   83.64%   83.61%   -0.03%     
==========================================
  Files          79       79              
  Lines        6230     6239       +9     
==========================================
+ Hits         5211     5217       +6     
- Misses       1019     1022       +3     
Files Changed Coverage Δ
quetz/dao.py 88.74% <ø> (ø)
quetz/main.py 89.89% <ø> (ø)
quetz/cli.py 74.68% <75.00%> (-0.08%) ⬇️
quetz/config.py 90.20% <100.00%> (ø)
quetz/hooks.py 82.60% <100.00%> (ø)
quetz/jobs/rest_models.py 87.17% <100.00%> (ø)
quetz/metrics/view.py 68.75% <100.00%> (ø)
quetz/pkgstores.py 68.01% <100.00%> (ø)
quetz/rest_models.py 98.20% <100.00%> (+0.02%) ⬆️
quetz/tasks/mirror.py 88.09% <100.00%> (-1.03%) ⬇️
... and 1 more

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@rominf
Copy link
Contributor Author

rominf commented Aug 30, 2023

If there is no default, first pydantic.Field argument should be omitted (None means that the default argument is None).

but

To preserve compatibility, introduce the ChannelWithOptionalName for /channels patch method.

I'm relying on the test suite and/or your knowledge of what's Optional and what's not since the codebase is new to me, and I might miss something.

cc @beenje

@rominf rominf marked this pull request as ready for review August 30, 2023 20:28
@rominf rominf force-pushed the rominf-mypy-libraries branch 3 times, most recently from 0f6a482 to 3813b10 Compare August 30, 2023 21:17
@rominf rominf mentioned this pull request Aug 30, 2023
1 task
@rominf rominf force-pushed the rominf-mypy-libraries branch 2 times, most recently from 11f0891 to e0cf4ab Compare September 3, 2023 17:51
@rominf
Copy link
Contributor Author

rominf commented Sep 3, 2023

It looks like the test test_download_remote_file_in_parallel is flaky: there is a problem in the test or the code. I haven't touched this place, and the previous run with the same code succeeded (I just fixed the commit message in the last force push).

The link to the job: https://github.com/mamba-org/quetz/actions/runs/6065939126/job/16455972862?pr=658

@wolfv
Copy link
Member

wolfv commented Sep 4, 2023

Hey @rominf indeed, that test is unfortunately flaky (has been this way since a rather long time).

@wolfv wolfv added the enhancement New feature or request label Sep 4, 2023
Preparation for mamba-org#646

* Remove `ignore_missing_imports = true` from mypy configuration.
* Run mypy in the same environment instead of separate to check types
  in dependencies like fastapi.
* Move mypy dependencies from pre-commit configuration to `setup.cfg`.
* Update mypy dependencies there.
* Move `rq` from `environment.yml` to `setup.cfg`: conda-forge version:
  1.9.0, pypi version : 1.15.1 (two years difference; types were added).
* Add libraries with missing types to ignore list in mypy
  configuration.
* Add pydantic mypy plugin.
* Allow running mypy without explicit paths.
* Update GitHub Actions.
* Temporarily add ignore `annotation-unchecked` to make mypy pass.
* Fix new mypy issues:
  * Use https://github.com/hauntsaninja/no_implicit_optional to make
    `Optional` explicit.
  * If there is no default, the first `pydantic.Field` argument should
    be omitted (`None` means that the default argument is `None`).
  * Refactor `_run_migrations`. There were two different paths: one for
    normal execution and another one for testing. Simplify arguments and
    the function code, and introduce a new mock `run_migrations`.
  * To preserve compatibility, introduce `ChannelWithOptionalName` for
    the `/channels` patch method. Note that the solution is a bit dirty
    (I had to use `type: ignore[assignment]`) to minimize the number of
    models and the diff.
  * Trivial errors.
@rominf
Copy link
Contributor Author

rominf commented Sep 24, 2023

Rebased, now tests pass.

@rominf
Copy link
Contributor Author

rominf commented Feb 3, 2024

A reminder about the PR.

Feel free to close the PR if its continuation is not beneficial. I am open to rebasing and improving it though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants