Closed shimpeko closed 2 years ago
Base: 48.19% // Head: 47.86% // Decreases project coverage by -0.32%
:warning:
Coverage data is based on head (
64ca30f
) compared to base (2d94048
). Patch coverage: 38.09% of modified lines in pull request are covered.
:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.
Could this be configured via pyproject.toml
rather than as arguments? I think one of the big advantages of delfino
is that users don't need to know the arguments etc. they need to pass.
My thinking is that if we end up proxying lots of mypy
options, then users might as well just use mypy
directly. There are exceptions to this, e.g. the --maxfail
argument on test
is useful for TDD.
Interested in @radeklat 's thoughts
I asked Shimpei about the motivation for this on Slack:
I’m using it here https://github.com/cookpad/global-python-utils/pull/124/files#diff-e0c3db65bec6563fb1667c02e1eb87c07363e9aa59e7eeb6c6dbba526beabfeaR32.
I agree with Jack on exposing this as a config option instead. As a list of one or more folders that should be checked strictly. It will make it more reusable too because no custom command will be needed. The implementation in global-python-utils already does that, only has the folders hardcoded.
Something like:
[tool.delfino.mypy]
strict_directories = [
"src",
]
Thank you for your comments. I'll implement typecheck.strict_path
configuration.
Could this be configured via pyproject.toml rather than as arguments? I think one of the big advantages of delfino is that users don't need to know the arguments etc. they need to pass. My thinking is that if we end up proxying lots of mypy options, then users might as well just use mypy directly. There are exceptions to this, e.g. the --maxfail argument on test is useful for TDD.
I think it is fine to have optional arguments with default values as the command can be run without knowing those options. Optional arguments are more flexible than pyproject.toml as we can configure them with python codes in sub/child commands.
In my case, I want to use python code to decide which path (can be given by --path
option) to apply the --strict
option, like;
strict_path = delfino.sources_directory
target_paths = [delfino.sources_directory, delfino.tests_directory, COMMANDS_DIRECTORY]
if path:
target_paths = [Path(p) for p in path]
grouped_paths = groupby(target_paths, lambda current_path: strict_path in current_path.parents or current_path == strict_path)
for force_typing, group in grouped_paths:
click_context.invoke(typecheck, path=[str(g) for g in group], strict=force_typing)
For me, delfino is another invoke but more useful because;
And to maximise flexibility for option 2, I think it is better to make things configurable through command options (w/ default value) rather than pyproject.toml unless those options are project wides (shared by multiple commands). I also think it maybe reasonable to make command options configurable through both pytproject.toml and commands arguments.
I agree with the second point about proxy. My idea is to configure options with sub/child commands so that we don't need to pass options when executing commands.
I agree with Jack on exposing this as a config option instead. As a list of one or more folders that should be checked strictly. It will make it more reusable too because no custom command will be needed. The implementation in global-python-utils already does that, only has the folders hardcoded.
I think it is reasonable to add something like mypy.strict_path
to pyproject.toml. It adds new capability to the typecheck commands.
Would like to add the followings for the typecheck command.
filepaths
argument : To overwrite the target directory for mypystrict_directories
config: To specify directory to be checked with--strict
option.With this change, we will be able to specify mode per path.
For example we can run mypy for
/src
with strict and for/test
without strict.See https://github.com/radeklat/delfino/pull/28#issuecomment-1245531786 for the use case.