Skip to content

Conversation

bkeryan
Copy link
Collaborator

@bkeryan bkeryan commented Mar 21, 2025

  • This contribution adheres to CONTRIBUTING.md.

  • I've updated CHANGELOG.md if applicable.

  • I've added tests applicable for this pull request

What does this Pull Request accomplish?

Use PEP 585 – Type Hinting Generics In Standard Collections and do other Python 3.9 syntax upgrades:

  • Ran Get-ChildItem -Recurse "*.py" | ForEach-Object { pyupgrade --py39-plus $_ } using the latest pyupgrade (installed via pipx).

Use PEP 604 – Allow writing union types as X | Y where possible:

  • Added from __future__ import annotations to most files containing from typing import .... This allows using type hint syntax from the future.
  • Re-ran pyupgrade. This uses X | Y syntax if the file already has from __future__ import annotations.

I did not remove the hardcoded Optional[...] references from docstrings.

Why should this Pull Request be merged?

Reduce number of typing imports.

Remove usage of typing.Optional, which people often confuse with default arguments.

What testing has been done?

Ran ni-python-styleguide, mypy, and pytest locally.

@github-actions
Copy link
Contributor

Test Results

    34 files  ±0      34 suites  ±0   54m 10s ⏱️ - 1m 46s
 2 382 tests ±0   2 026 ✅  -  2    356 💤 + 2  0 ❌ ±0 
42 864 runs  ±0  36 602 ✅  - 10  6 262 💤 +10  0 ❌ ±0 

Results for commit 143fb05. ± Comparison against base commit fcddb56.

This pull request skips 2 tests.
tests.component.test_interpreter ‑ test___error_code_with_hardcoded_error_message___get_error_string___returns_hardcoded_error_message[grpc_init_kwargs--200284]
tests.component.test_interpreter ‑ test___error_code_with_hardcoded_error_message___get_error_string___returns_hardcoded_error_message[grpc_init_kwargs-DAQmxErrors.SAMPLES_NOT_YET_AVAILABLE]

@bkeryan bkeryan changed the title [DO NOT MERGE UNTIL 25C2] Upgrade to Python 3.9 syntax Upgrade to Python 3.9 syntax Apr 1, 2025
@bkeryan bkeryan merged commit 9317cb9 into master Apr 1, 2025
17 checks passed
@bkeryan bkeryan deleted the users/bkeryan/pyupgrade-py39-plus branch April 1, 2025 18:11
@bkeryan bkeryan mentioned this pull request Jul 11, 2025
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants