Skip to content

[docs] Include a real listing of the flags strict enables in the online documentation #19062

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 16 commits into
base: master
Choose a base branch
from

Conversation

wyattscarpenter
Copy link
Contributor

Fixes #19061

Currently, https://mypy.readthedocs.io/en/stable/command_line.html just says

You can see the list of flags enabled by strict mode in the full mypy --help output.

Which makes cross-referencing the documentation difficult. Instead, there should be the same list there as appears when running mypy --help: eg

--warn-unused-configs, --disallow-any-generics,
--disallow-subclassing-any, --disallow-untyped-
calls, --disallow-untyped-defs, --disallow-
incomplete-defs, --check-untyped-defs, --disallow-
untyped-decorators, --warn-redundant-casts,
--warn-unused-ignores, --warn-return-any, --no-
implicit-reexport, --strict-equality, --extra-
checks

Ideally this section would be automatically generated from the code.

This pull request accomplishes this.

This comment has been minimized.

@wyattscarpenter wyattscarpenter marked this pull request as ready for review May 9, 2025 09:52

This comment has been minimized.

This comment has been minimized.

I remembered that sometimes this documentation gets processed into other formats, like a man page. I'm not sure what the process is there, but let's save them a little potential embarassment of introducing but not having a list
Copy link
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅


def write_doc(self, docname: str, doctree: document) -> None:
super().write_doc(docname, doctree)
self._ref_to_doc.update({_id: docname for _id in doctree.ids})

def _add_strict_list(self) -> None:
strict_flags: list[str]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this explicit decl necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not, I just left it in to document the type. What with define_options being so far away and us only using the middle of its tuple. I don't feel strongly about it one way or the other 🤷

return parser, strict_flag_names, strict_flag_assignments


def process_options(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Amazing, this func that contains some real logic is only 200 LOC now, much better than 1000+ to scroll!

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.

Should include a real listing of the flags strict enables in the online documentation.
2 participants