We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Literal
class
from typing import Literal from dataclasses import dataclass from typeguard import typechecked @dataclass @typechecked class A(object): optimizer: Literal[ "Adadelta", "Adagrad", "Adam", "Adamax", "Ftrl", "Nadam", "RMSprop" ] = None print(A(optimizer='Foo'), A(optimizer=None), A(optimizer=True), A(optimizer=5))
Output:
(A(optimizer='Foo'), A(optimizer=None), A(optimizer=True), A(optimizer=5), A(optimizer=0.2))
Expectation: Error on all of these. This should work though A(optimizer='Adagrad')…
A(optimizer='Adagrad')
The text was updated successfully, but these errors were encountered:
@agronholm In the meantime, I've started maintaining the old enforce repo, and added Literal support with: SamuelMarks/enforce@349e6f8
enforce
Sorry, something went wrong.
I don't think @typechecked can be applied to dataclass types as discussed in #161 and #61
@typechecked
@svermeulen Might give your gist a shot https://gist.github.com/svermeulen/8a6ad727113a6d07f78332152c1d33b2
I suppose avoiding maintaining my own runtime type checker is a good idea…
As stated above, covered by #161 so I'm closing this one.
No branches or pull requests
Output:
Expectation:
Error on all of these. This should work though
A(optimizer='Adagrad')
…The text was updated successfully, but these errors were encountered: