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

Force kw_only for all config classes #21

Merged
merged 1 commit into from
Jul 31, 2024
Merged

Force kw_only for all config classes #21

merged 1 commit into from
Jul 31, 2024

Conversation

kirkbrauer
Copy link
Contributor

Improve config code style to prevent confusion with different arguments.

@kirkbrauer kirkbrauer requested a review from NickCao July 30, 2024 18:26
@@ -56,7 +56,9 @@ def client_create(
if out is None and ClientConfig.exists(name):
raise click.ClickException(f"A client with the name '{name}' already exists.")

config = ClientConfig(name, endpoint, token, drivers=ClientConfigDrivers(allow.split(","), unsafe))
config = ClientConfig(
name=name, endpoint=endpoint, token=token, drivers=ClientConfigDrivers(allow=allow.split(","), unsafe=unsafe)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hehe in some others cases it's much better, in this case it makes the code too verbose. ':D

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good news is that this is internal

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true :)


def load_or_create() -> Self:
"""Check if a user config exists, otherwise create an empty one."""
if UserConfig.exists() is False:
if os.path.exists(UserConfig.BASE_CONFIG_PATH) is False:
os.makedirs(UserConfig.BASE_CONFIG_PATH)
config = UserConfig(None)
config = UserConfig(current_client=None)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would keep it in cases like this, but without enforcing it may be. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'm just worried if we get more properties it'll get confusing.

ClientConfig,
"load",
return_value=ClientConfig(
name="testclient", endpoint="abc", token="123", drivers=ClientConfigDrivers(allow=[], unsafe=False)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

helps here... ':D :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this makes it look a lot more like the resulting YAML :D

Copy link
Member

@mangelajo mangelajo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's go with it, and let's re-analyze if it got too annoying, as you said, this is internal.

@@ -56,7 +56,9 @@ def client_create(
if out is None and ClientConfig.exists(name):
raise click.ClickException(f"A client with the name '{name}' already exists.")

config = ClientConfig(name, endpoint, token, drivers=ClientConfigDrivers(allow.split(","), unsafe))
config = ClientConfig(
name=name, endpoint=endpoint, token=token, drivers=ClientConfigDrivers(allow=allow.split(","), unsafe=unsafe)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true :)

@mangelajo mangelajo merged commit 89fa7a4 into main Jul 31, 2024
3 checks passed
@kirkbrauer kirkbrauer deleted the config_kw_only branch August 7, 2024 14:15
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

Successfully merging this pull request may close these issues.

2 participants