Skip to content

Commit d86bc2c

Browse files
authored
Fix **kwargs typehints (#2884)
We have `**kwargs: Optional[Dict[str, Any]]` in a few places in our codebase. This is actually means "each kwarg is of type `Optional[Dict[str, Any]]`. The right thing to do is `**kwargs: Any`. Once our minimum supported Python version is 3.11, we will be able to have more precise type hints for `**kwargs`. https://typing.python.org/en/latest/spec/callables.html#unpack-kwargs Before the change (with Pylance typeChecking set to "standard"): <img width="800" height="144" alt="image" src="https://github.com/user-attachments/assets/9006e127-211f-4112-bedb-92a17f012063" /> After the change (with Pylance typeChecking set to "standard"): <img width="1225" height="222" alt="image" src="https://github.com/user-attachments/assets/9a89f11f-7e98-4f52-a897-b39c645ead61" />
1 parent dc87380 commit d86bc2c

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

source/pip/qsharp/openqasm/_compile.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121

2222
def compile(
2323
source: Union[str, Callable],
24-
*args,
25-
**kwargs: Optional[Dict[str, Any]],
24+
*args: Any,
25+
**kwargs: Any,
2626
) -> QirInputData:
2727
"""
2828
Compiles the OpenQASM source code into a program that can be submitted to a

source/pip/qsharp/openqasm/_estimate.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
def estimate(
2323
source: Union[str, Callable],
2424
params: Optional[Union[Dict[str, Any], List, EstimatorParams]] = None,
25-
*args,
26-
**kwargs: Optional[Dict[str, Any]],
25+
*args: Any,
26+
**kwargs: Any,
2727
) -> EstimatorResult:
2828
"""
2929
Estimates the resource requirements for executing OpenQASM source code.

source/pip/qsharp/openqasm/_import.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
def import_openqasm(
1818
source: str,
19-
**kwargs: Optional[Dict[str, Any]],
19+
**kwargs: Any,
2020
) -> Any:
2121
"""
2222
Imports OpenQASM source code into the active Q# interpreter.

source/pip/qsharp/openqasm/_run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def run(
3838
] = None,
3939
qubit_loss: Optional[float] = None,
4040
as_bitstring: bool = False,
41-
**kwargs: Optional[Dict[str, Any]],
41+
**kwargs: Any,
4242
) -> List[Any]:
4343
"""
4444
Runs the given OpenQASM program for the given number of shots.

0 commit comments

Comments
 (0)