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

[DO NOT MERGE UNTIL 25C2] Upgrade to Python 3.9 syntax #681

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

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.

Copy link

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]

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