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

Use future annotations #555

Merged
merged 6 commits into from
Jan 4, 2025
Merged

Use future annotations #555

merged 6 commits into from
Jan 4, 2025

Conversation

tony
Copy link
Member

@tony tony commented Jan 4, 2025

Changes

chore: Support PEP 563 from __future__ import annotations

Using PEP 563's deferred resolution of annotations avoids the computation cost of symbols we imported solely used for type-checking.

Ruff:

PEP 563: https://peps.python.org/pep-0563/

Copy link

codecov bot commented Jan 4, 2025

Codecov Report

Attention: Patch coverage is 99.62121% with 1 line in your changes missing coverage. Please review.

Project coverage is 88.68%. Comparing base (df8480c) to head (aa5e23f).
Report is 7 commits behind head on master.

Files with missing lines Patch % Lines
src/libtmux/pane.py 94.73% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #555      +/-   ##
==========================================
- Coverage   88.76%   88.68%   -0.08%     
==========================================
  Files          36       36              
  Lines        3934     3924      -10     
  Branches      360      362       +2     
==========================================
- Hits         3492     3480      -12     
  Misses        307      307              
- Partials      135      137       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

tony added 3 commits January 4, 2025 07:52
Fixed 606 errors:
- conftest.py:
      1 × TC003 (typing-only-standard-library-import)
      1 × I002 (missing-required-import)
- docs/conf.py:
      2 × UP007 (non-pep604-annotation)
      2 × UP037 (quoted-annotation)
      1 × I002 (missing-required-import)
- src/libtmux/__about__.py:
      1 × I002 (missing-required-import)
- src/libtmux/__init__.py:
      1 × I002 (missing-required-import)
- src/libtmux/_internal/dataclasses.py:
      1 × UP037 (quoted-annotation)
      1 × I002 (missing-required-import)
- src/libtmux/_internal/query_list.py:
     47 × UP037 (quoted-annotation)
     37 × UP007 (non-pep604-annotation)
      1 × I002 (missing-required-import)
- src/libtmux/_vendor/_structures.py:
      1 × I002 (missing-required-import)
      1 × UP037 (quoted-annotation)
- src/libtmux/_vendor/version.py:
     12 × UP007 (non-pep604-annotation)
      5 × UP037 (quoted-annotation)
      1 × F401 (unused-import)
      1 × I002 (missing-required-import)
- src/libtmux/common.py:
      8 × UP007 (non-pep604-annotation)
      2 × F401 (unused-import)
      1 × UP037 (quoted-annotation)
      1 × I002 (missing-required-import)
      1 × TC003 (typing-only-standard-library-import)
- src/libtmux/constants.py:
      1 × I002 (missing-required-import)
- src/libtmux/exc.py:
      7 × UP007 (non-pep604-annotation)
      1 × UP037 (quoted-annotation)
      1 × I002 (missing-required-import)
- src/libtmux/formats.py:
      1 × I002 (missing-required-import)
- src/libtmux/neo.py:
    129 × UP007 (non-pep604-annotation)
      9 × UP037 (quoted-annotation)
      1 × I002 (missing-required-import)
- src/libtmux/pane.py:
     55 × UP007 (non-pep604-annotation)
     20 × UP037 (quoted-annotation)
      2 × Q000 (bad-quotes-inline-string)
      1 × I002 (missing-required-import)
- src/libtmux/pytest_plugin.py:
      1 × UP037 (quoted-annotation)
      1 × TC003 (typing-only-standard-library-import)
      1 × I002 (missing-required-import)
      1 × I001 (unsorted-imports)
- src/libtmux/server.py:
     23 × UP007 (non-pep604-annotation)
      7 × UP037 (quoted-annotation)
      1 × I002 (missing-required-import)
- src/libtmux/session.py:
     29 × UP007 (non-pep604-annotation)
     20 × UP037 (quoted-annotation)
      1 × I002 (missing-required-import)
      1 × TC001 (typing-only-first-party-import)
      1 × I001 (unsorted-imports)
- src/libtmux/test.py:
      7 × UP037 (quoted-annotation)
      5 × UP007 (non-pep604-annotation)
      3 × I001 (unsorted-imports)
      2 × TC003 (typing-only-standard-library-import)
      1 × F401 (unused-import)
      1 × I002 (missing-required-import)
      1 × TC001 (typing-only-first-party-import)
      1 × PYI034 (non-self-return-type)
- src/libtmux/window.py:
     52 × UP007 (non-pep604-annotation)
     22 × UP037 (quoted-annotation)
      1 × I002 (missing-required-import)
- tests/_internal/test_query_list.py:
      3 × UP007 (non-pep604-annotation)
      1 × I002 (missing-required-import)
      1 × I001 (unsorted-imports)
      1 × TC003 (typing-only-standard-library-import)
- tests/legacy_api/test_common.py:
      4 × UP007 (non-pep604-annotation)
      1 × TC001 (typing-only-first-party-import)
      1 × I002 (missing-required-import)
- tests/legacy_api/test_pane.py:
      1 × I001 (unsorted-imports)
      1 × I002 (missing-required-import)
      1 × TC001 (typing-only-first-party-import)
- tests/legacy_api/test_server.py:
      1 × I001 (unsorted-imports)
      1 × I002 (missing-required-import)
      1 × TC001 (typing-only-first-party-import)
- tests/legacy_api/test_session.py:
      1 × I001 (unsorted-imports)
      1 × TC001 (typing-only-first-party-import)
      1 × I002 (missing-required-import)
- tests/legacy_api/test_tmuxobject.py:
      1 × I001 (unsorted-imports)
      1 × TC001 (typing-only-first-party-import)
      1 × I002 (missing-required-import)
- tests/legacy_api/test_version.py:
      2 × UP007 (non-pep604-annotation)
      2 × UP037 (quoted-annotation)
      1 × I002 (missing-required-import)
- tests/legacy_api/test_window.py:
      1 × I001 (unsorted-imports)
      1 × TC001 (typing-only-first-party-import)
      1 × I002 (missing-required-import)
- tests/test_common.py:
      4 × UP007 (non-pep604-annotation)
      1 × I002 (missing-required-import)
      1 × TC001 (typing-only-first-party-import)
- tests/test_dataclasses.py:
      1 × TC003 (typing-only-standard-library-import)
      1 × TC001 (typing-only-first-party-import)
      1 × I002 (missing-required-import)
      1 × I001 (unsorted-imports)
- tests/test_pane.py:
      1 × I001 (unsorted-imports)
      1 × I002 (missing-required-import)
      1 × TC001 (typing-only-first-party-import)
- tests/test_pytest_plugin.py:
      1 × I001 (unsorted-imports)
      1 × I002 (missing-required-import)
      1 × TC002 (typing-only-third-party-import)
- tests/test_server.py:
      1 × I001 (unsorted-imports)
      1 × TC001 (typing-only-first-party-import)
      1 × I002 (missing-required-import)
- tests/test_session.py:
      1 × TC001 (typing-only-first-party-import)
      1 × I002 (missing-required-import)
- tests/test_test.py:
      1 × I002 (missing-required-import)
- tests/test_tmuxobject.py:
      1 × I001 (unsorted-imports)
      1 × TC001 (typing-only-first-party-import)
      1 × I002 (missing-required-import)
- tests/test_version.py:
      2 × UP007 (non-pep604-annotation)
      2 × UP037 (quoted-annotation)
      1 × I002 (missing-required-import)
- tests/test_window.py:
      1 × I001 (unsorted-imports)
      1 × I002 (missing-required-import)
      1 × TC001 (typing-only-first-party-import)

Found 1976 errors (606 fixed, 1370 remaining).
35 files reformatted, 9 files left unchanged

uv run ruff check --select ALL . --fix --unsafe-fixes --preview --show-fixes; uv run ruff format .
@tony tony force-pushed the future-annotations branch from 23fe1c6 to bb13d70 Compare January 4, 2025 13:52
Fixed 6 errors:
- src/libtmux/_vendor/version.py:
    1 × I001 (unsorted-imports)
    1 × UP006 (non-pep585-annotation)
- src/libtmux/test.py:
    2 × I001 (unsorted-imports)
    1 × UP006 (non-pep585-annotation)
    1 × TC003 (typing-only-standard-library-import)

Found 1374 errors (6 fixed, 1368 remaining).
44 files left unchanged

uv run ruff check --select ALL . --fix --unsafe-fixes --preview --show-fixes; uv run ruff format .
@tony tony force-pushed the future-annotations branch from 735c73b to 08ffc8b Compare January 4, 2025 14:31
@tony tony force-pushed the future-annotations branch from 08ffc8b to aa5e23f Compare January 4, 2025 15:24
@tony tony merged commit c511658 into master Jan 4, 2025
27 checks passed
@tony tony deleted the future-annotations branch January 4, 2025 15:28
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.

1 participant