Skip to content
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

Move pygmt.show_versions function to _show_versions.py #3277

Merged
merged 2 commits into from
May 29, 2024
Merged

Conversation

weiji14
Copy link
Member

@weiji14 weiji14 commented May 29, 2024

Description of proposed changes

Move pygmt.show_versions() function from __init__.py to _show_versions.py because it got too long after #3244, and ruff v0.4.6 introduced a minor change in astral-sh/ruff#11521 that counts every branch in the match statement as a single statement, causing pygmt.show_versions() to exceed the 50 statement limit.

Reference:

Fixes #3276

Reminders

  • Run make format and make check to make sure the code follows the style guide.
  • Add tests for new features or tests that would have caught the bug that you're fixing.
  • Add new public functions/methods/classes to doc/api/index.rst.
  • Write detailed docstrings for all functions/methods.
  • If wrapping a new module, open a 'Wrap new GMT module' issue and submit reasonably-sized PRs.
  • If adding new functionality, add an example to docstrings or tutorials.
  • Use underscores (not hyphens) in names of Python files and directories.

Slash Commands

You can write slash commands (/command) in the first line of a comment to perform
specific operations. Supported slash command is:

  • /format: automatically format and lint the code

Shorten some code in the pygmt.show_versions function to fit it under 50 statements.
@weiji14 weiji14 added maintenance Boring but important stuff for the core devs skip-changelog Skip adding Pull Request to changelog labels May 29, 2024
@weiji14 weiji14 self-assigned this May 29, 2024
@weiji14 weiji14 marked this pull request as ready for review May 29, 2024 00:39
Extracted _get_clib_info, _get_module_version, _get_ghostscript_version, _check_ghostscript_version functions out of show_versions(). Moved some Python standard library imports to the top-level instead of nesting in the function.
@weiji14 weiji14 changed the title ruff: Fix PLR0915 Too many statements on pygmt.show_versions() Move pygmt.show_versions function to _show_versions.py May 29, 2024
@seisman seisman added this to the 0.13.0 milestone May 29, 2024
@seisman seisman merged commit a42be05 into main May 29, 2024
18 of 19 checks passed
@seisman seisman deleted the fix-ruff-plr0915 branch May 29, 2024 05:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance Boring but important stuff for the core devs skip-changelog Skip adding Pull Request to changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move the pygmt.show_versions function to a separate file?
2 participants