Skip to content

add mypy support #106

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

sneakers-the-rat
Copy link
Contributor

fix #100

my nerves are shot and i am procrastinating making my scipy posters badly

added a basic mypy config, these are just the config settings i like, so requesting review from @Midnighter who had the previous config in there. took out pydantic-specific stuff bc i figure we don't want to assume people will be using pydantic.

i also renamed the option from use_type to use_mypy and changed the prompt text accordingly - everyone should use type annotations :) and also this switch does just enable/disable mypy anyway. i still don't really like how pydoclint has no option for "ignore type annotations in function signatures" and it must be either "all functions must have type signatures" or "no functions may have type signatures" - that's enough of a problem for me that i wouldn't use pydoclint and by proxy this template, but a problem for another time.

other stuff:

  • added exception to the ruff FBT001 rule in test code which i think is silly - it forbids the presence of any positional boolean variables. like ok maybe in some circumstances like the ones they cite in the rule explanation are a code smell but banning an entire type from signatures is overkill, especially in tests.
  • i noticed the non-hatch gh action didn't have the job where mypy is run in the hatch version, so i added that.

@lwasser
Copy link
Member

lwasser commented Jul 2, 2025

Oh, thank you for this. I had this on my list because all of the mypy stuff is commented out in the "full" version of the template. I'll leave to Moritz for review I just wanted to thank you for this!!

Also, get your poster done 🙃

Copy link
Contributor

@Midnighter Midnighter left a comment

Choose a reason for hiding this comment

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

Good changes! Some minor comments that you can take as you like.

@@ -151,11 +151,11 @@ use_precommit:
default: "{% if template_mode != 'minimal' %}yes{% else %}no{% endif %}"
help: "Do you want to pre-commit hooks to format your code on save?"

use_types:
use_mypy:
Copy link
Contributor

Choose a reason for hiding this comment

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

I originally went with use_types, as folks might want to run pyright or another alternative to mypy. It's fair to commit to mypy, though, especially as this is targeted more at beginners.

""")

root = generated(use_hatch_envs=use_hatch_envs, use_mypy=True)
pkg_path = root / "src" / "alien_clones"
Copy link
Contributor

Choose a reason for hiding this comment

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

Can the name be gotten from the generated project somehow? Would be better than hard-coding it here.

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.

mypy config in pyproject.toml
3 participants