Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Improve cli help somewhat #19073

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

Draft
wants to merge 31 commits into
base: master
Choose a base branch
Loading
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
c95306e
failed attempt, very regex-heavy
wyattscarpenter May 9, 2025
5dbb010
ok I mean it works now but it doubles up insertions
wyattscarpenter May 9, 2025
c5c0857
works perfectly
wyattscarpenter May 9, 2025
82eb394
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 9, 2025
15236bd
get the strict flags another way, to make all the tests pass
wyattscarpenter May 9, 2025
4081906
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 9, 2025
b415f0f
generate the strict list in the build dir, so there won't be any funk…
wyattscarpenter May 9, 2025
00580de
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 9, 2025
98bc704
um, I meant srcdir. Sure.
wyattscarpenter May 9, 2025
a546416
bruh
wyattscarpenter May 9, 2025
c044f80
refactor out define_options
wyattscarpenter May 10, 2025
6a47e7d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 10, 2025
9ba2c9b
remove --experimental from dmypy's options after 'a short transition'…
wyattscarpenter May 10, 2025
8087150
move --use-fine-grained-cache to Incremental group
wyattscarpenter May 10, 2025
3a75ee6
create new 'experimental' group, rescuing --enable-incomplete-feature…
wyattscarpenter May 10, 2025
4f1e460
rename Optional arguments to Utility arguments, since all arguments a…
wyattscarpenter May 10, 2025
2a8a8e2
The metavar overrides the default of displaying the choices, so we ha…
wyattscarpenter May 10, 2025
8c61a64
update documentation
wyattscarpenter May 10, 2025
350fd38
update documentation so it's clear that an int field doesn't need to …
wyattscarpenter May 10, 2025
c0aa284
begin to enforce rules, although it's surprisingly failing
wyattscarpenter May 10, 2025
c76183d
continue automating, and correcting
wyattscarpenter May 10, 2025
72f1e5c
blacken
wyattscarpenter May 11, 2025
31dc2ff
remove the concern about links as it no longer seems to be useful
wyattscarpenter May 11, 2025
2c45a29
improve cli formatting error message and also linewrapping
wyattscarpenter May 11, 2025
67dd115
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 11, 2025
185371a
readd link I accidentally deleted
wyattscarpenter May 11, 2025
91233ca
name that occurs in python 3.9
wyattscarpenter May 11, 2025
52d2a4c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 11, 2025
26e221d
fix ci problems (type errors)
wyattscarpenter May 11, 2025
9706862
hold on a minute, this needs an s
wyattscarpenter May 11, 2025
01324aa
my arguments were in the wrong order
wyattscarpenter May 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
works perfectly
  • Loading branch information
wyattscarpenter committed May 11, 2025
commit c5c085776db8d0dde60815e1c7f7fcd0dfc613b3
5 changes: 4 additions & 1 deletion 5 docs/source/command_line.rst
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,10 @@ of the above sections.
:option:`mypy --help` output.

Note: the exact list of flags enabled by running :option:`--strict` may change
over time.
over time. For the current version of mypy, the list is:

.. include:: strict_list.rst


.. option:: --disable-error-code

Expand Down
23 changes: 6 additions & 17 deletions 23 docs/source/html_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import json
import os
import re
import textwrap
from pathlib import Path
from typing import Any
Expand All @@ -18,27 +17,18 @@ class MypyHTMLBuilder(StandaloneHTMLBuilder):
def __init__(self, app: Sphinx, env: BuildEnvironment) -> None:
super().__init__(app, env)
self._ref_to_doc = {}
self._add_strict_list()

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_to_doc(self) -> None:
target_filename = "command_line.html"
p = Path(self.outdir) / target_filename
text = p.read_bytes()
lead_in = b"over time."
c = text.count(lead_in)
complaint = f"Expected '{lead_in}' in {target_filename}, so I could add the strict flags after it, but "
if c < 1:
raise ValueError(complaint+"it was not there.")
elif c > 1:
raise ValueError(complaint+"it occurred in multiple locations, so I don't know what to do.")
help_text = process_options(['-c', 'pass'])
strict_part = help_text[2].split(": ")[1]
def _add_strict_list(self) -> None:
p = Path(self.outdir).parent.parent / "source" / "strict_list.rst"
strict_part = ", ".join(f":option:`{s} <mypy {s}>`" for s in process_options(['-c', 'pass'])[2])
if not strict_part or strict_part.isspace() or len(strict_part) < 20 or len(strict_part) > 2000:
raise ValueError(f"{strict_part=}, which doesn't look right.")
p.write_bytes(text.replace(lead_in, lead_in+b" The current list is: " + bytes(strict_part, encoding="ascii")))
raise ValueError(f"{strict_part=}, which doesn't look right (by a simple heuristic).")
p.write_text(strict_part)

def _verify_error_codes(self) -> None:
from mypy.errorcodes import error_codes
Expand Down Expand Up @@ -74,7 +64,6 @@ def _write_ref_redirector(self) -> None:
def finish(self) -> None:
super().finish()
self._write_ref_redirector()
self._add_strict_to_doc()


def setup(app: Sphinx) -> dict[str, Any]:
Expand Down
6 changes: 4 additions & 2 deletions 6 mypy/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,11 +471,13 @@ def process_options(
fscache: FileSystemCache | None = None,
program: str = "mypy",
header: str = HEADER,
) -> tuple[list[BuildSource], Options, str]:
) -> tuple[list[BuildSource], Options, list[str]]:
"""Parse command line arguments.

If a FileSystemCache is passed in, and package_root options are given,
call fscache.set_package_root() to set the cache's package root.

Returns a tuple of: a list of source file, an Options collected from flags, and the computed list of strict flags.
"""
stdout = stdout or sys.stdout
stderr = stderr or sys.stderr
Expand Down Expand Up @@ -1532,7 +1534,7 @@ def set_strict_flags() -> None:
# exceptions of different types.
except InvalidSourceList as e2:
fail(str(e2), stderr, options)
return targets, options, strict_help
return targets, options, strict_flag_names


def process_package_roots(
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.