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 Python type hints #359

Merged
merged 2 commits into from
Dec 4, 2024
Merged

add Python type hints #359

merged 2 commits into from
Dec 4, 2024

Conversation

egpbos
Copy link
Member

@egpbos egpbos commented Oct 21, 2024

Added a subsection on type hints, following the discussion in #310. Also added a few cool libraries, e.g. FastAPI that was mentioned by Bouwe in #54 and Typer from the same author.

Fixes #310.

Checklist

SIGNIFICANT changes / additions, e.g. new chapters

  • I checked whether the contribution fits in The Turing Way before considering contributing to this Guide.
  • I discussed my contribution in an issue and took into account feedback.

ALL contributions

  • I previewed my changes locally using e.g. python3 -m http.server 4000 and confirmed they work correctly.
  • I checked for broken links, e.g. using the link checker GitHub Action workflow, or locally by using docker run --init -it -v `pwd`:/docs lycheeverse/lychee /docs --config=docs/lychee.toml, at least for the files I changed.
  • My name was added to the CITATION.cff file.

Added a subsection on type hints, following the discussion in #310. Also added a few cool libraries, e.g. FastAPI that was mentioned by Bouwe in #54 and Typer from the same author.

Fixes #310.
@egpbos egpbos requested a review from bouweandela October 21, 2024 20:31
Copy link
Member

@bouweandela bouweandela left a comment

Choose a reason for hiding this comment

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

Thanks @egpbos, very nice addition!

language_guides/python.md Outdated Show resolved Hide resolved
language_guides/python.md Outdated Show resolved Hide resolved
language_guides/python.md Outdated Show resolved Hide resolved
language_guides/python.md Outdated Show resolved Hide resolved
language_guides/python.md Outdated Show resolved Hide resolved
@egpbos
Copy link
Member Author

egpbos commented Nov 19, 2024

@stefsmeets We talked today about attrs and how you used it for nested-yaml / dataclass validation and preferred it over Pydantic. In this PR, I happened to add a bit of text on Pydantic. I haven't looked at attrs yet, but do you think it makes sense to mention it in here as well? Or does it deserve a topic of its own? Is schema / data validation perhaps a useful topic for a section of the data chapter?

@stefsmeets
Copy link
Member

I think it makes sense, I find attrs to be much more approachable than pydantic. The attrs docs have a really nice section on comparing the different tools: https://www.attrs.org/en/stable/why.html

@egpbos
Copy link
Member Author

egpbos commented Nov 20, 2024

Briefly browsing PROTEUS' use of attrs, it seems like a nice lightweight tool for value validation. I'm not sure how (or even if) Pydantic handles this, but certainly seems useful. I don't think it should go under this PR, though, it's a topic independent of type hints.

@egpbos
Copy link
Member Author

egpbos commented Nov 20, 2024

Whoops, missed your comment @stefsmeets before posting mine just now. Agree, it looks nice and lightweight. Lets make a separate issue.

@egpbos egpbos mentioned this pull request Nov 20, 2024
@egpbos
Copy link
Member Author

egpbos commented Dec 4, 2024

The attrs discussion will be continued in #364.

@bouweandela bouweandela merged commit 77690e2 into main Dec 4, 2024
2 checks passed
@bouweandela bouweandela deleted the type-hints branch December 4, 2024 14:25
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.

Add information on type hints to Python chapter
3 participants