Skip to content

Update type annotations#7364

Merged
pavoljuhas merged 6 commits intoquantumlib:mainfrom
Akshita07:update-type-annotations
May 21, 2025
Merged

Update type annotations#7364
pavoljuhas merged 6 commits intoquantumlib:mainfrom
Akshita07:update-type-annotations

Conversation

@Akshita07
Copy link
Copy Markdown
Contributor

@Akshita07 Akshita07 commented May 21, 2025

Updates following type annotations:

  • typing.Dict to dict
  • typing.List to list
  • typing.Tuple to tuple
  • typing.Set to set
  • typing.FrozenSet to frozenset
  • typing.Type to type
  • typing.Union to X | Y
  • typing.Optional to X | None

Addresses issue [#7339]

@github-actions github-actions bot added the size: M 50< lines changed <250 label May 21, 2025
@github-actions github-actions bot added size: L 250< lines changed <1000 and removed size: M 50< lines changed <250 labels May 21, 2025
@codecov
Copy link
Copy Markdown

codecov bot commented May 21, 2025

Codecov Report

Attention: Patch coverage is 99.10714% with 2 lines in your changes missing coverage. Please review.

Project coverage is 98.68%. Comparing base (e9a592d) to head (badf4ca).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...services/quantum_engine_service/transports/grpc.py 50.00% 1 Missing ⚠️
.../quantum_engine_service/transports/grpc_asyncio.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7364   +/-   ##
=======================================
  Coverage   98.68%   98.68%           
=======================================
  Files        1112     1112           
  Lines       97599    97588   -11     
=======================================
- Hits        96315    96306    -9     
+ Misses       1284     1282    -2     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Akshita07
Copy link
Copy Markdown
Contributor Author

@pavoljuhas , @dstrain115 ruff check fix is missing a few type updates but suggests to fix manually, such as follows

TParamKey = Union[str, sympy.Expr]

I am not sure if these can be updated to variable: X | Y . Please suggest.

@pavoljuhas
Copy link
Copy Markdown
Collaborator

@pavoljuhas , @dstrain115 ruff check fix is missing a few type updates but suggests to fix manually, such as follows

TParamKey = Union[str, sympy.Expr]

I am not sure if these can be updated to variable: X | Y . Please suggest.

Yes, please go ahead with these manually.

@Akshita07
Copy link
Copy Markdown
Contributor Author

@pavoljuhas

With manual updates like variable: X | Y such as
Screenshot 2025-05-21 at 11 25 17 PM

I am getting following errors with mypy

Screenshot 2025-05-21 at 11 18 24 PM

So, I am leaving these occurrences as is for this PR, unless there is another suggestion to fix these manually.

@Akshita07 Akshita07 marked this pull request as ready for review May 21, 2025 18:24
@Akshita07 Akshita07 requested review from a team, mrwojtek, verult, vtomole and wcourtney as code owners May 21, 2025 18:24
@pavoljuhas pavoljuhas self-assigned this May 21, 2025
Passes   ruff check --target-version=py311 --select=UP037,TC001,TC002,UP006,UP007
@pavoljuhas pavoljuhas requested a review from dabacon as a code owner May 21, 2025 21:16
@pavoljuhas
Copy link
Copy Markdown
Collaborator

With manual updates like variable: X | Y ...
I am getting following errors with mypy

I don't see it on my side, perhaps there is some difference in your virtual environment.
To have reproducible results, the best is to create a new environment in the same way as in the CI workflow here

- name: Install mypy
run: pip install -r dev_tools/requirements/mypy.env.txt
- name: Type check
run: check/mypy

I have pushed badf4ca for the final issues detected by ruff.

@pavoljuhas pavoljuhas enabled auto-merge May 21, 2025 21:26
@pavoljuhas pavoljuhas added this pull request to the merge queue May 21, 2025
Merged via the queue into quantumlib:main with commit 513f309 May 21, 2025
35 checks passed
@Akshita07
Copy link
Copy Markdown
Contributor Author

@pavoljuhas Thank you. I'll create a new environment.

@pavoljuhas
Copy link
Copy Markdown
Collaborator

@pavoljuhas Thank you. I'll create a new environment.

👍 Also, please use check/mypy to make sure source paths are correctly set for mypy.

BichengYing pushed a commit to BichengYing/Cirq that referenced this pull request Jun 20, 2025
Updates following type annotations:

- typing.Dict to dict
- typing.List to list
- typing.Tuple to tuple
- typing.Set to set
- typing.FrozenSet to frozenset
- typing.Type to type
- typing.Union to X | Y
- typing.Optional to X | None

Addresses issue [quantumlib#7339]

---------

Co-authored-by: Pavol Juhas <juhas@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: L 250< lines changed <1000

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants