Migrate state, cli_args, and output out of main.py#1893
Merged
Conversation
ca45c90 to
81218ed
Compare
scottnemes
reviewed
May 16, 2026
|
|
||
| if TYPE_CHECKING: | ||
|
|
||
| def __getattr__(self, name: str) -> Any: ... |
Contributor
There was a problem hiding this comment.
This seems like it short circuits the mypy checks; was it done to get past errors that were happening? Ran this through Claude and it recommends something like the below instead to prevent future errors not being caught by mypy:
if TYPE_CHECKING:
from cli_helpers.tabular_output import TabularOutputFormatter
from configobj import ConfigObj
class _MyCliState(Protocol):
# External attributes supplied by the concrete class (MyCli).
config: ConfigObj
my_cnf: ConfigObj
logfile: TextIOWrapper | None
prompt_session: Any
prompt_format: str
prompt_lines: int
explicit_pager: bool
ptoolkit_style: Any
helpers_style: Any
helpers_warnings_style: Any
main_formatter: TabularOutputFormatter
redirect_formatter: TabularOutputFormatter
# Provided by AppStateMixin.
def read_my_cnf(self, cnf: ConfigObj, keys: list[str]) -> dict[str, Any]: ...
# Provided by OutputMixin itself; declared so cross-method calls type-check.
def log_output(self, output: str | AnyFormattedText) -> None: ...
def get_output_margin(self, status: str | None = None) -> int: ...
def get_reserved_space(self) -> int: ...
class OutputMixin:
def output_timing(self: _MyCliState, timing: str, is_warnings_style: bool = False) -> None:
...
Will approve still in case you do not think that is an issue however.
Contributor
Author
There was a problem hiding this comment.
Thanks! Will try it.
scottnemes
approved these changes
May 16, 2026
81218ed to
d3fb1eb
Compare
Create a mycli/app_state.py, mycli/cli_args.py, and mycli/output.py, factoring logic out of mycli/main.py, with no functional change.
d3fb1eb to
8bae90a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Create a
mycli/app_state.py,mycli/cli_args.py, andmycli/output.py, factoring logic out ofmycli/main.py, with no functional change.Like other refactors, this could be seen as incomplete in various ways, but it moves us forward on reducing LOC in
main.py(which is now a third of the size from before refactoring started).Checklist
changelog.mdfile.AUTHORSfile (or it's already there).