Skip to content

DEPR: should we deprecate astropy.utils.console.terminal_size ? #16042

Closed

Description

@neutrinoceros

This function was added in #2878, and first released in astropy 1.0 (feb 2015)
At the time, it made perfect sense to ship our own function for this, since Python 2 was still supported, and os.get_terminal_size was never fully portable (to this day, it only supports UNIX and Windows).

However, there's been an equally portable function in the standard lib since Python 3.3: https://docs.python.org/3/library/shutil.html#shutil.get_terminal_size

While not a 1:1 replacement (shutil.get_terminal_size doesn't have a file argument), I note that console.terminal_size is very rarely used internally (only twice, one of which is a test !), so I think it'd make sense to just deprecate it. Thoughts ?

Activity

  1. pllim commented on Feb 14, 2024

    @pllim
    Member

    Hmm weird that file= was implemented but we don't actually use it. Since this would affect Table, I would like to see if there are objections from astropy.table maintainers: @taldcroft and @mhvk

    If no objection, maybe open a draft PR to deprecate it. @saimn , should such deprecation happen in v6.1 or v7.0 given how long it has already existed?

    Personally, I am fine with deprecating this, especially if Python standard library already gives something similar now. Thanks for bringing this up!

  2. added
    API changePRs and issues that change an existing API, possibly requiring a deprecation period
    on Feb 14, 2024
  3. mhvk commented on Feb 14, 2024

    @mhvk
    Contributor

    Looks to me like it can be deprecated indeed - the file argument seems used only in a context where one is resizing, so clearly connected to a real terminal.

  4. saimn commented on Feb 16, 2024

    @saimn
    Contributor

    should such deprecation happen in v6.1 or v7.0 given how long it has already existed?

    6.1 is fine, the question is more when to remove it and actually break things.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    API changePRs and issues that change an existing API, possibly requiring a deprecation periodRefactoringutils

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions