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

exclude variables annotated with ClassVar #75

Open
adrianmgg opened this issue Feb 27, 2022 · 2 comments
Open

exclude variables annotated with ClassVar #75

adrianmgg opened this issue Feb 27, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@adrianmgg
Copy link

ClassVar is (quoting from here in typing docs, emphasis mine):

Special type construct to mark class variables.

[...] a variable annotation wrapped in ClassVar indicates that a given attribute is intended to be used as a class variable and should not be set on instances of that class.

I think it would make sense to exclude any variables whose annotations are wrapped in ClassVar from the list of arguments.

@RadixSeven
Copy link

It would be nice to have an annotation specifically to make Tap ignore variables, e.g., @tap_ignore. Since ClassVar would be less common, asking users to use both might be sufficient. My use case is that I have a complex type that I create from multiple arguments in process_args (right now, I just say not to use it in the comment).

class ArgParser(Tap):
    params: List[float] = []
    """ Even number of entries. Each pair is the mean and 
    standard deviation of the Gaussian underlying a 
    log-normal distribution """
    @tap_ignore
    distributions: List[LogNormal] = []
    """ process_args will construct this from params after 
    checking params for validity """

@martinjm97 martinjm97 added the enhancement New feature or request label Mar 28, 2022
@martinjm97
Copy link
Collaborator

Hi @adrianmgg and @RadixSeven,

We like both of these ideas! Thank you so much for bringing up this issue. We'll try to get to this soon, but any PRs are welcome and appreciated.

Thanks,
Kyle and Jesse

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants