Skip to content

Deprecate click.get_terminal_size() in favor of stdlib shutil.#1737

Merged
davidism merged 1 commit into
pallets:masterfrom
jdufresne:get-terminal-size
Feb 15, 2021
Merged

Deprecate click.get_terminal_size() in favor of stdlib shutil.#1737
davidism merged 1 commit into
pallets:masterfrom
jdufresne:get-terminal-size

Conversation

@jdufresne
Copy link
Copy Markdown
Contributor

Since Python 3.3, the stdlib provides the function
shutil.get_terminal_size(). Now that the project has dropped Python 2
support, the compatibility shim is no longer necessary.

The stdlib version returns a named tuple. So rather than indexing "0",
can use the more self-documenting attribute "columns".

Docs available at:
https://docs.python.org/3/library/shutil.html#shutil.get_terminal_size

Fixes #1736

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.

Since Python 3.3, the stdlib provides the function
shutil.get_terminal_size(). Now that the project has dropped Python 2
support, the compatibility shim is no longer necessary.

The stdlib version returns a named tuple. So rather than indexing "0",
can use the more self-documenting attribute "columns".

Docs available at:
https://docs.python.org/3/library/shutil.html#shutil.get_terminal_size
@davidism davidism added this to the 8.0.0 milestone Feb 15, 2021
@davidism davidism merged commit 4f17161 into pallets:master Feb 15, 2021
@jdufresne jdufresne deleted the get-terminal-size branch February 15, 2021 21:04
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Mar 2, 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.

Deprecate click.get_terminal_size() in favor of stdlib shutil.get_terminal_size()

2 participants