Skip to content

path type supports pathlib#1804

Merged
davidism merged 1 commit into
masterfrom
pathlib
Mar 5, 2021
Merged

path type supports pathlib#1804
davidism merged 1 commit into
masterfrom
pathlib

Conversation

@davidism
Copy link
Copy Markdown
Member

@davidism davidism commented Mar 5, 2021

  • click.Path(path_type=pathlib.Path) returns the value as a pathlib object. Technically any class is allowed, but this is only intended for pathlib.
  • Use os.fsdecode and fsencode to convert str and bytes. Since Python 2 isn't supported more, the value from the command line will never be bytes.
  • Remove the internal path_type attribute, which was confusingly named (the path_type parameter is stored as type), and was just name.title().

Checklist:

  • Add tests that demonstrate the correct behavior of the change. Tests should fail without the change.
  • Add or update relevant docs, in the docs folder and in code.
  • Add an entry in CHANGES.rst summarizing the change and linking to the issue.
  • Add .. versionchanged:: entries in any relevant code docs.
  • Run pre-commit hooks and fix any issues.
  • Run pytest and tox, no tests failed.

@davidism davidism added this to the 8.0.0 milestone Mar 5, 2021
@davidism davidism merged commit 4c7399e into master Mar 5, 2021
@davidism davidism deleted the pathlib branch March 5, 2021 04:38
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Mar 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

click.Path returns str, not pathlib.Path

1 participant