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

Pytype fixes #740

Closed
wants to merge 3 commits into from
Closed

Pytype fixes #740

wants to merge 3 commits into from

Conversation

folded
Copy link
Contributor

@folded folded commented Apr 8, 2024

Ensure that python code bundled with stim passes pytype --strict-none-binding.

@@ -220,10 +219,10 @@ def iter_collect(*,

def collect(*,
num_workers: int,
tasks: Union[Iterator['sinter.Task'], Iterable['sinter.Task']],
tasks: Union[Iterator[Task], Iterable[Task]],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary to change? Because these methods are in the external API, I prefer to name the types how users would use them ("sinter.Task" instead of just "Task").

shots=bit_packed_detection_event_data,
bit_packed_shots=True,
bit_packed_predictions=True,
return_weights=False,
)
if isinstance(result, tuple):
return result[0] # pymatching returned predictions and weights
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this ever actually executed, it would be a bug. Raise an exception, or do a cast.

@@ -361,7 +361,7 @@ def test_decode_fails_correctly(decoder: str, force_streaming: Optional[bool]):
with open(d / 'bad_dets.b8', 'wb') as f:
f.write(b'!')

if 'vacuous' not in decoder:
if 'vacuous' not in decoder and decoder_obj is not None:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should assert it's not none instead of disabling the testing of the decoder that wasn't.

y_func: Callable[[TaskStats], Union[Fit, float, int]],
group_func: _GroupFunc[TCurveId] = lambda _: None,
filter_func: Callable[[TaskStats], Any] = lambda _: True,
plot_args_func: Union[_PlotArgsFunc2[TCurveId], _PlotArgsFunc3[TCurveId]] = lambda index, group_key, group_stats: dict(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an example where I sorta prefer for the exposed API to not mention the deprecated functionality, even though the method still technically supports it. I can't remove the backwards compat, but I can hide the complication of the backwards compat from new users.

@Strilanc Strilanc force-pushed the main branch 3 times, most recently from 7c26e1c to e5172a4 Compare September 10, 2024 06:24
@Strilanc
Copy link
Collaborator

Closing due to stale comments and growing merge conflicts. Still open to fixing type errors in downstream tools.

@Strilanc Strilanc closed this Sep 21, 2024
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