Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 6, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix compat.is_darwin
This fixes compat.is_darwin to use sys.platform instead of os.name
so that it is True on macOS systems instead of always being False.
The deprecation rationale in compat.py is accordingly adjusted.

Together with c01fe76, this largely addresses #1731.
  • Loading branch information
EliahKagan committed Nov 4, 2023
commit 562bdee8110267f2861625f40aa403a72f000def
15 changes: 6 additions & 9 deletions git/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,14 @@

# DEPRECATED attributes providing shortcuts to operating system checks based on os.name.
#
# - is_win and is_posix are deprecated because it is clearer, and helps avoid bugs, to
# write out the os.name checks explicitly. For example, is_win is False on Cygwin, but
# is often assumed to be True.
# These are deprecated because it is clearer, and helps avoid bugs, to write out the
# os.name or sys.platform checks explicitly, especially in cases where it matters which
# is used. For example, is_win is False on Cygwin, but is often assumed True. To detect
# Cygwin, use sys.platform == "cygwin". (Also, in the past, is_darwin was unreliable.)
#
# - is_darwin is deprecated because it is always False on all systems, as os.name is
# never "darwin". For macOS, you can check for sys.platform == "darwin". (As on other
# Unix-like systems, os.name == "posix" on macOS. This is also the case on Cygwin.)
#
is_win: bool = os.name == "nt"
is_win = os.name == "nt"
is_posix = os.name == "posix"
is_darwin = os.name == "darwin"
is_darwin = sys.platform == "darwin"

defenc = sys.getfilesystemencoding()

Expand Down