grass.script: Make grass_path keyword only in init #3689
Merged
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.
This makes the grass_path parameter a keyword-only argument (PEP 3102). While this technically breaks the 8.0 API for 8.4, the documentation only shows grass_path as a keyword argument, grass_path is required to be a keyword argument when location and mapset are omitted, and given the automation triggered by grass_path=None, any usage of grass_path is likely limited (the usage would have to be as positional argument to trigger the incompatibility).
API
Originally posted as a comment in #3438:
Worked in 8.0-8.3:
With this PR:
Never possible:
With this PR, code without an explicit grass_path working in 8.0-8.3 needs to be rewritten:
Back to my earlier comment, the usage which is no longer available with this PR was never promoted. Instead, the documentation for grass.script.setup.init shows:
There is a heuristic in the function which determines the path automatically, so the idea is that in most cases, grass_path does not have to be supplied at all. (For example, I don't see any usages in this repo or on GitHub.) Having grass_path passed as a keyword argument (with explicit name), rather than a positional one, is the intended usage (based on the example, number and type of parameters and my judgement of what I intended back in 8.0 times).
One can say that this PR limits the usage to intended usage by fixing bug in the function specification.