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

Enable ruff's flake8-future-annotations (FA) rules #2855

Merged
merged 6 commits into from
Dec 10, 2023
Merged

Enable ruff's flake8-future-annotations (FA) rules #2855

merged 6 commits into from
Dec 10, 2023

Conversation

seisman
Copy link
Member

@seisman seisman commented Dec 6, 2023

Description of proposed changes

Enable ruff's flake8-future annotations (FA) rules. This rule set contains two rules, FA100 and FA102.

Generally, these two rules recommend using from __future__ import annotations so that we can use some new type hinting syntax in old Python versions. For example, Union[str, None] can be rewritten as str | None for Python>=3.10 (introduced in PEP 604). It won't work for Python 3.9 (PyGMT's minimum supported Python version) unless we use from __future__ import annotations.

For more details, please refer to:

```
pygmt/datasets/load_remote_dataset.py:61:12: FA100 Missing `from __future__ import annotations`, but uses `typing.Union`
   |
59 |     name: str
60 |     long_name: str
61 |     units: Union[str, None]
   |            ^^^^^ FA100
62 |     resolutions: dict[str, Resolution]
63 |     extra_attributes: dict
   |
```
```
pygmt/datasets/load_remote_dataset.py:63:12: UP007 Use `X | Y` for type annotations
   |
61 |     name: str
62 |     long_name: str
63 |     units: Union[str, None]
   |            ^^^^^^^^^^^^^^^^ UP007
64 |     resolutions: dict[str, Resolution]
65 |     extra_attributes: dict
   |
   = help: Convert to `X | Y`
```
@seisman seisman added maintenance Boring but important stuff for the core devs needs review This PR has higher priority and needs review. labels Dec 6, 2023
@seisman seisman added this to the 0.11.0 milestone Dec 6, 2023
@seisman seisman requested a review from a team December 8, 2023 12:22
@seisman seisman added final review call This PR requires final review and approval from a second reviewer and removed needs review This PR has higher priority and needs review. labels Dec 8, 2023
@seisman seisman merged commit 09f2452 into main Dec 10, 2023
17 checks passed
@seisman seisman deleted the ruff/FA branch December 10, 2023 11:52
@seisman seisman removed the final review call This PR requires final review and approval from a second reviewer label Dec 10, 2023
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants