Improve overall commands handling of envconfig#181
Conversation
* As Pydantic takes care of validation the envconfig, we don't have to check that anymore * Remove any checking of if context.envconfig is None * Adjust ManagedGitRepo to allow string or Repo as remote_url This makes it easier * Use `cast(Envconfig, context.envconfig)` to avoid type errors
We have already Pydantic validation, no need to check.
Coverage ReportFor commit d3e2bca Click to expand Coverage Report Name Stmts Miss Branch BrPart Cover
--------------------------------------------------------------------------------
+ src/docbuild/cli/cmd_check/process.py 58 0 22 1 98.8%
+ src/docbuild/utils/pidlock.py 79 1 14 1 97.8%
+ src/docbuild/config/xml/stitch.py 48 1 12 1 96.7%
+ src/docbuild/cli/cmd_validate/process.py 178 5 52 4 96.1%
+ src/docbuild/cli/callback.py 35 0 10 2 95.6%
+ src/docbuild/cli/cmd_metadata/metaprocess.py 168 10 42 7 91.9%
- src/docbuild/cli/cmd_config/__init__.py 9 1 0 0 88.9%
- src/docbuild/cli/cmd_cli.py 86 11 6 3 84.8%
- src/docbuild/cli/cmd_check/__init__.py 18 5 2 0 65.0%
- src/docbuild/cli/cmd_build/__init__.py 13 5 0 0 61.5%
- src/docbuild/cli/cmd_metadata/__init__.py 27 10 2 0 58.6%
- src/docbuild/cli/cmd_config/environment.py 11 6 2 0 38.5%
--------------------------------------------------------------------------------
+ TOTAL 2734 55 624 19 97.6%
47 files skipped due to complete coverage. |
Hi @tomschr, thanks a lot for the awesome work. Much appreciated! This is a fantastic cleanup. By using our move to Pydantic, you've significantly reduced the 'noise' of defensive coding across the CLI commands. The code is much leaner and follows better DevSecOps and Pythonic practices. LGTM, Approved. One small request: could you please add a fragment file for example: |
This is added in commit c1366ea |
Declare envconfig as EnvConfig type in DocBuildContext
|
I also removed the |
Awesome. Please merge it. |
Some of our docbuild commands checks for an empty
.envconfiglike this:This is futile now and a leftover as it's all covered by Pydantic.
This PR changes:
src/docbuild/cli/cmd_c14n/*files.Introduced a cast (=> Changeenv = cast(EnvConfig, context.envconfig)) to make editor not complain.DocBuildContext.envconfigto be aEnvConfigobject and not adict.EnvConfigobjects and notdicts to simulate the behavior of the model.ManagedGitReposhould allow str andRepoin__init__to pass any of the two objects without taking care. This make it easier when called. Raise aTypeErrorwhen there is a different type.test_process_no_envconfigtest function as there is no need to test this anymore when Pydantic already validates it. Failed configs are tested elsewhere.