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

Add type annotations #358

Closed
jku opened this issue May 18, 2021 · 4 comments · Fixed by #843
Closed

Add type annotations #358

jku opened this issue May 18, 2021 · 4 comments · Fixed by #843

Comments

@jku
Copy link
Collaborator

jku commented May 18, 2021

We should type annotate our functions:

  • Most importantly we should type annotate public methods (this should enable TUF to type check its calls)
  • internal methods are useful to annotate as well (and may be necessary to enable static type checking in this repo)

This is companion to #357 (using mypy in securesystemslib): I think the process goes like this (although it's partially speculation: I've not tried this yet)

  • annotate at least one module (at least the public methods)
  • when public methods are annotated, this module can be enabled in TUF mypy config
  • when one whole module is annotated, we can do Use mypy to statically check sources #357 and start type checking here

Repeat steps for each module

Using mypy with an existing codebase may be useful: we may want to try tools to automatically generate type annotations: they might work well for this sort of code

@sechkova
Copy link
Contributor

sechkova commented Jun 7, 2021

mypy is now included in the CI run with #361.
Also the util and storage modules are type annotated with #361 and #362.

@jku
Copy link
Collaborator Author

jku commented Jun 8, 2021

The other modules used in TUF (metadata api) are:

exceptions
formats
keys
signer

So I guess those should be next in line (but I think we could also enable checks in TUF module-by-module if there are trickier modules that can't be annotated in the next weeks)

@jku
Copy link
Collaborator Author

jku commented Jun 11, 2021

Also, I think we need to add a securesystemslib/py.typed marker file in the repo: https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-type-hints-for-third-party-library
Otherwise TUF can't use the SSLib annotations (and we definitely want that because we want to find things like theupdateframework/python-tuf#1442)

lukpueh added a commit to lukpueh/securesystemslib that referenced this issue Feb 21, 2022
* New upstream release includes among other things:
  - bug fix in the Signer abstract base class (secure-systems-lab#348)
  - machinery for static type checking with mypy (secure-systems-lab#361)
  - type annotations for a few modules (progress tracked in secure-systems-lab#358)
  - enhancements in the Signature class (secure-systems-lab#383, secure-systems-lab#387)

* d/control:
  - bump standards version to 4.6.0.1

Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
@jku
Copy link
Collaborator Author

jku commented Apr 18, 2024

Also, I think we need to add a securesystemslib/py.typed

3 years later this is still true 😂

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 a pull request may close this issue.

2 participants