Deprecate compat.is_<platform>, rewriting all uses by EliahKagan · Pull Request #1732 · gitpython-developers/GitPython · GitHub
Skip to content

Deprecate compat.is_<platform>, rewriting all uses#1732

Merged
Byron merged 2 commits intogitpython-developers:mainfrom
EliahKagan:compat
Nov 6, 2023
Merged

Deprecate compat.is_<platform>, rewriting all uses#1732
Byron merged 2 commits intogitpython-developers:mainfrom
EliahKagan:compat

Conversation

@EliahKagan
Copy link
Copy Markdown
Member

@EliahKagan EliahKagan commented Nov 4, 2023

Fixes #1731

Major changes:

  • Remove all uses of is_win and is_posix in git/ and test/, replacing them with os.name == "nt" and os.name == "posix", respectively.
  • Fix is_darwin by changing it to use sys.platform instead of os.name which is never "darwin".
  • Add a comment in the git.compat module above the definitions of is_win, is_posix, and is_darwin stating that they are deprecated and recommending that os.name (or, where applicable, sys.platform) be used directly instead for clarity (and sometimes accuracy).

There were no uses of is_darwin to be replaced. Although it had been used at one time, the last reference to it appears to have been removed in 4545762 (#1295).

This doesn't emit a DeprecationWarning when those attributes are accessed from the git.compat module. (That might be valuable thing to do in the future, if the git.compat module is to remain non-deprecated overall. See discussion in #1731.)

Two related less consequential changes are also included:

  • Improve ordering and grouping of imports, in modules where they were already being changed as a result of no longer needing to import is_<platform> (usually is_win) from git.compat.
  • Make minor revisions to a few comments, for readability. (This is in addition to somewhat more substantial revisions of comments where rewording was related to replacing uses of is_<platform>.)

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

is_darwin is always False (os.name is never "darwin")

2 participants