Skip to content

Commit

Permalink
black tool
Browse files Browse the repository at this point in the history
  • Loading branch information
mathleur committed Feb 5, 2024
1 parent 536d92f commit 2e08cc0
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 30 deletions.
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ build-backend = "poetry.core.masonry.api"
[tool.ruff]
line-length = 120
lint.extend-select = ["I"]

[tool.black]
line-length = 120
4 changes: 1 addition & 3 deletions tests/dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ class NestedConfig(ConfigModel):


class Config(ConfigModel):
user_email: Annotated[
str, Field(), EnvVar("USER_EMAIL"), CLIArg("--user-email")
] = "foo"
user_email: Annotated[str, Field(), EnvVar("USER_EMAIL"), CLIArg("--user-email")] = "foo"
user_key: Annotated[str, Field(description="Your API Key"), EnvVar("XYZ")] = "xyz"
url: str = "http://example.com"
secure: bool = Field(False)
Expand Down
8 changes: 2 additions & 6 deletions tests/test_cli_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,8 @@ class NestedConfig(ConfigModel):


class Config(ConfigModel):
test_email: Annotated[
str, Field(), EnvVar("TEST_EMAIL"), CLIArg("--test-email")
] = "[email protected]"
test_key: Annotated[
str, Field(description="Test API Key"), EnvVar("TEST_KEY")
] = "default_key"
test_email: Annotated[str, Field(), EnvVar("TEST_EMAIL"), CLIArg("--test-email")] = "[email protected]"
test_key: Annotated[str, Field(description="Test API Key"), EnvVar("TEST_KEY")] = "default_key"
nested_config: NestedConfig = NestedConfig()


Expand Down
8 changes: 2 additions & 6 deletions tests/test_env_var.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,8 @@ class NestedConfig(ConfigModel):


class Config(ConfigModel):
test_email: Annotated[
str, Field(), EnvVar("TEST_EMAIL"), CLIArg("--test-email")
] = "[email protected]"
test_key: Annotated[
str, Field(description="Test API Key"), EnvVar("TEST_KEY")
] = "default_key"
test_email: Annotated[str, Field(), EnvVar("TEST_EMAIL"), CLIArg("--test-email")] = "[email protected]"
test_key: Annotated[str, Field(description="Test API Key"), EnvVar("TEST_KEY")] = "default_key"
nested_config: NestedConfig = NestedConfig()


Expand Down
8 changes: 2 additions & 6 deletions tests/test_no_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,8 @@


class Config(ConfigModel):
test_email: Annotated[
str, Field(), EnvVar("TEST_EMAIL"), CLIArg("--test-email")
] = "[email protected]"
test_key: Annotated[
str, Field(description="Test API Key"), EnvVar("TEST_KEY")
] = "default_key"
test_email: Annotated[str, Field(), EnvVar("TEST_EMAIL"), CLIArg("--test-email")] = "[email protected]"
test_key: Annotated[str, Field(description="Test API Key"), EnvVar("TEST_KEY")] = "default_key"


def test_no_cli():
Expand Down
12 changes: 3 additions & 9 deletions tests/test_subclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,8 @@ def get(self, target):
return self.cache[target.__name__]
except KeyError:
# Deduplicate classes by __name__
deduped = list(
{subcls.__name__: subcls for subcls in target.__subclasses__()}.values()
)
subclasses = {target.__name__: target} | {
k: v for subcls in deduped for k, v in self.get(subcls).items()
}
deduped = list({subcls.__name__: subcls for subcls in target.__subclasses__()}.values())
subclasses = {target.__name__: target} | {k: v for subcls in deduped for k, v in self.get(subcls).items()}
subclasses[target.__name__] = target
self.cache[target.__name__] = subclasses
return subclasses
Expand All @@ -72,9 +68,7 @@ def get(self, target):
# Constuct a union type out of the subclasses
# Field(discriminator="name") tells pydantic to look at the name
# field to decide what type of the union to attempt to parse
action_subclasses_union = Annotated[
Union[action_subclasses], Field(discriminator="name")
]
action_subclasses_union = Annotated[Union[action_subclasses], Field(discriminator="name")]


class Config(ConfigModel):
Expand Down

0 comments on commit 2e08cc0

Please sign in to comment.