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

Proof of Concept: Types and MyPy #1906

Merged
merged 5 commits into from
Nov 13, 2024
Merged

Conversation

juanitorduz
Copy link
Contributor

This is the first iteration in the journey to add type hints to the project #299 .

We can add types on small and modular iterations, and the community can help (so these can be labeled as good first issues). I found this nice blog https://breadcrumbscollector.tech/mypy-how-to-use-it-in-my-project/ that provides tips on how to add types gradually.

Let me you what you think about this proof-of-concept PR

@@ -278,7 +279,7 @@ def scan_wrapper(
length,
reverse,
rng_key=None,
substitute_stack=[],
substitute_stack=None,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is something I spotted while adding hints. We would want to avoid having mutables as defaults.

@@ -4,6 +4,7 @@ lint: FORCE
ruff check .
ruff format . --check
python scripts/update_headers.py --check
mypy --install-types --non-interactive numpyro
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ignore_missing_imports = true

[[tool.mypy.overrides]]
module = [
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, we can keep adding the modules we want to check. Eventually, we would like to simply remove this and check everything

@fehiepsi
Copy link
Member

LGTM! The changes are pretty clean to me. Do you want to submit this?

@juanitorduz
Copy link
Contributor Author

LGTM! The changes are pretty clean to me. Do you want to submit this?

Yes, for me, we can merge, and I continue (bit by bit) adding hints (you can also advertise this task and maybe others can help as well, maybe even some of the ones that did it for Pyro ;) )

@fehiepsi fehiepsi merged commit d55d209 into pyro-ppl:master Nov 13, 2024
4 checks passed
@fehiepsi
Copy link
Member

Thanks @juanitorduz!

cc @ordabayevy

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