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

mypy does not recognize keyword arguments to json_serializable_dataclass instances #2769

Closed
kevinsung opened this issue Feb 13, 2020 · 6 comments
Labels
area/json area/mypy kind/health For CI/testing/release process/refactoring/technical debt items

Comments

@kevinsung
Copy link
Collaborator

To reproduce:

  1. Create a file test.py in cirq/ with the following contents:
import dataclasses
from cirq import protocols


@dataclasses.dataclass
class A:
    a: int


@protocols.json_serializable_dataclass
class B:
    b: int


A(a=0)
B(b=0)
  1. Execute check/mypy. This gives the following output:

cirq/test.py:16: error: Unexpected keyword argument "b" for "B"

@mpharrigan
Copy link
Collaborator

@dabacon
Copy link
Collaborator

dabacon commented May 8, 2020

Do we want to remove json_serializable_dataclass decorator? It doesn't look like ti is used anywhere.

@kevinsung
Copy link
Collaborator Author

It's used once in experiments/cross_entropy_benchmarking.py but that shouldn't prevent us from removing it.

@mpharrigan
Copy link
Collaborator

I would not object to removing it, if the drawbacks exceed the marginal benefit

@balopat balopat added area/json area/mypy kind/health For CI/testing/release process/refactoring/technical debt items labels Sep 1, 2020
@mpharrigan
Copy link
Collaborator

this annotation should be deprecated: #4460

use the dataclass helper function in a regular ol' method instead

@95-martin-orion
Copy link
Collaborator

Resolved by #5208.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/json area/mypy kind/health For CI/testing/release process/refactoring/technical debt items
Projects
None yet
Development

No branches or pull requests

5 participants