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

Annotate the library (add py.typed) #970

Merged
merged 3 commits into from
Mar 25, 2025

Conversation

jku
Copy link
Collaborator

@jku jku commented Mar 15, 2025

I'd like to statically analyze calls to securesystemslib in other projects

  • securesystemslib needs a py.typed file for that
  • securesystemslib.hash is the only public module that is not annotated: current plan is to deprecate it before next release

Changelog:

  • Add py.typed
  • refactor mypy config into pyproject.toml
  • make mypy config stricter but don't try to lint tests with it
  • Run lint on oldest supported python version to let mypy find annotation issues on that python
  • Tell mypy to ignore hash module
  • Fix a bunch of small annotation issues elsewhere in code

@lukpueh
Copy link
Member

lukpueh commented Mar 17, 2025

This PR is not just about hash module, right? Also, what's missing for marking this ready for review?

@jku
Copy link
Collaborator Author

jku commented Mar 17, 2025

This PR is not just about hash module, right?

yeah there's refactor (and tightening) of mypy config and minor annotation fixes that result from that

Also, what's missing for marking this ready for review?

possibly just fixing the PR message?

@jku jku marked this pull request as ready for review March 18, 2025 09:08
* Move config to pyproject.toml
* Turn on useful mypy options
* Don't check tests with mypy: too much to fix right now
* Add py.typed to announce this project is type annotated
* Fix various annotation issues

Issues remain in hash module

Signed-off-by: Jussi Kukkonen <[email protected]>
@jku
Copy link
Collaborator Author

jku commented Mar 18, 2025

Only change in this force-push is that FilesystemBackend.__new__() signature now remains compatible with what it was: I just used more "typing.Any".

@jku jku marked this pull request as draft March 19, 2025 11:31
@jku
Copy link
Collaborator Author

jku commented Mar 19, 2025

I will modify this so hash is left untouched by this PR: based on theupdateframework/python-tuf#2815 we can deprecate hash instead.

jku added 2 commits March 19, 2025 13:34
This is useful since it will notice use of too new features (or lack of
"from __future__ import annotations").

Signed-off-by: Jussi Kukkonen <[email protected]>
Plan is to deprecate hash soon.

Signed-off-by: Jussi Kukkonen <[email protected]>
@jku jku changed the title Annotate hash module Annotate the library (add py.typed) Mar 19, 2025
@jku jku marked this pull request as ready for review March 19, 2025 12:01
@jku
Copy link
Collaborator Author

jku commented Mar 19, 2025

This should be good to go now. python-tuf lint (with this securesystemslib, with mypy excludes removed) has some complaints but only in tests and seemingly for good reason.

@lukpueh lukpueh merged commit 0b6e018 into secure-systems-lab:main Mar 25, 2025
17 checks passed
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