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

change Configurable to support type inference in pycharm for new and from_config #162

Merged
merged 1 commit into from
Jul 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions padertorch/configurable.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,8 @@ def new(
The updates are used to create a config and this config is then used to
create the instance.
"""
return cls.from_config(cls.get_config(updates))
new: cls = cls.from_config(cls.get_config(updates))
return new

@classmethod
def get_config(
Expand Down Expand Up @@ -430,7 +431,7 @@ def get_config(
def from_config(
cls,
config,
) -> 'Configurable':
):
"""Produce a Configurable instance from a valid config."""
# TODO: assert do not use defaults

Expand Down Expand Up @@ -462,7 +463,7 @@ def from_config(
f'{pretty(config)}'
)

new = config_to_instance(config)
new: cls = config_to_instance(config)
return new

@classmethod
Expand Down
Loading