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

Does the recent feature for typing_extensions.NotRequired support the functional syntax? #87

Closed
saeejithnair opened this issue Nov 17, 2023 · 2 comments

Comments

@saeejithnair
Copy link

Thanks for adding this feature! Is the parsing supposed to work with the functional syntax or does it only support the class-based syntax rn?

E.g. I just tried the following on v0.5.14 and neither of the two examples below seem to work and it shows up as required in the help text... Is there something wrong with my syntax? I'm on python3.9 so I'm importing these via typing_extensions instead of Typing as suggested here.

from typing_extensions import TypedDict, NotRequired
from typing import Callable, Literal, Optional, Type, Dict, Union

NerfMLPHiddenLayers_1 = TypedDict(
    "NerfMLPHiddenLayers1",
    {
        "hidden_layers.0": NotRequired[int],
        "hidden_layers.1": NotRequired[int],
        "hidden_layers.2": NotRequired[int],
        "hidden_layers.3": NotRequired[int],
        "hidden_layers.4": NotRequired[int],
        "hidden_layers.5": NotRequired[int],
        "hidden_layers.6": NotRequired[int],
        "hidden_layers.7": NotRequired[int],
    },
)

NerfMLPHiddenLayers_2 = TypedDict(
    "NerfMLPHiddenLayers2",
    {
        "hidden_layers.0": int,
        "hidden_layers.1": int,
        "hidden_layers.2": int,
        "hidden_layers.3": int,
        "hidden_layers.4": int,
        "hidden_layers.5": int,
        "hidden_layers.6": int,
        "hidden_layers.7": int,
    },
    total=False
)
image
brentyi added a commit that referenced this issue Nov 17, 2023
@brentyi
Copy link
Owner

brentyi commented Nov 17, 2023

Hi @saeejithnair, thanks for flagging this!

This looks like it's probably a bug, but I haven't been able to reproduce it. I just pushed a test that also checks this behavior in the CI. Do you mind sharing a runnable example, or perhaps more information about your Python environment? (like the typing_extensions version)

@brentyi
Copy link
Owner

brentyi commented Nov 17, 2023

Actually, I think I figured it out — there was an edge case when a TypedDict field had a default specified, which is probably the case in your NeRF config. I just did a release that should have the issue fixed. (if it's not would appreciate you letting me know!)

@brentyi brentyi closed this as completed Nov 17, 2023
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

No branches or pull requests

2 participants