Skip to content

Commit 5a8e55d

Browse files
authored
Merge pull request #373 from dbatten5/rename-types-module
Rename `types.py` module
2 parents 896675f + 5789ecb commit 5a8e55d

File tree

15 files changed

+49
-49
lines changed

15 files changed

+49
-49
lines changed

src/maison/config.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from maison import parsers
1111
from maison import protocols
1212
from maison import service
13-
from maison import types
13+
from maison import typedefs
1414

1515

1616
def _bootstrap_service(package_name: str) -> service.ConfigService:
@@ -83,7 +83,7 @@ def __str__(self) -> str:
8383
return f"<class '{self.__class__.__name__}'>"
8484

8585
@property
86-
def values(self) -> types.ConfigValues:
86+
def values(self) -> typedefs.ConfigValues:
8787
"""Return the user's configuration values.
8888
8989
Returns:
@@ -92,7 +92,7 @@ def values(self) -> types.ConfigValues:
9292
return self._values
9393

9494
@values.setter
95-
def values(self, values: types.ConfigValues) -> None:
95+
def values(self, values: typedefs.ConfigValues) -> None:
9696
"""Set the user's configuration values."""
9797
self._values = values
9898

@@ -145,7 +145,7 @@ def validate(
145145
self,
146146
schema: typing.Optional[type[protocols.IsSchema]] = None,
147147
use_schema_values: bool = True,
148-
) -> types.ConfigValues:
148+
) -> typedefs.ConfigValues:
149149
"""Validate the configuration.
150150
151151
Warning:

src/maison/config_parser.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import typing
55

66
from maison import errors
7-
from maison import types
7+
from maison import typedefs
88

99

1010
ParserDictKey = tuple[str, typing.Union[str, None]]
@@ -13,7 +13,7 @@
1313
class Parser(typing.Protocol):
1414
"""Defines the interface for a `Parser` class that's used to parse a config."""
1515

16-
def parse_config(self, file_path: pathlib.Path) -> types.ConfigValues:
16+
def parse_config(self, file_path: pathlib.Path) -> typedefs.ConfigValues:
1717
"""Parse a config file.
1818
1919
Args:
@@ -42,7 +42,7 @@ def register_parser(
4242
key = (suffix, stem)
4343
self._parsers[key] = parser
4444

45-
def parse_config(self, file_path: pathlib.Path) -> types.ConfigValues:
45+
def parse_config(self, file_path: pathlib.Path) -> typedefs.ConfigValues:
4646
"""See `Parser.parse_config`."""
4747
key: ParserDictKey
4848

src/maison/config_validator.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Holds the tools for validating a user's config."""
22

33
from maison import protocols
4-
from maison import types
4+
from maison import typedefs
55

66

77
class Validator:
@@ -11,8 +11,8 @@ class Validator:
1111
"""
1212

1313
def validate(
14-
self, values: types.ConfigValues, schema: type[protocols.IsSchema]
15-
) -> types.ConfigValues:
14+
self, values: typedefs.ConfigValues, schema: type[protocols.IsSchema]
15+
) -> typedefs.ConfigValues:
1616
"""See `Validator.validate`."""
1717
validated_schema = schema(**values)
1818
return validated_schema.model_dump()

src/maison/parsers/ini.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import configparser
44
import pathlib
55

6-
from maison import types
6+
from maison import typedefs
77

88

99
class IniParser:
@@ -12,7 +12,7 @@ class IniParser:
1212
Implements the `Parser` protocol
1313
"""
1414

15-
def parse_config(self, file_path: pathlib.Path) -> types.ConfigValues:
15+
def parse_config(self, file_path: pathlib.Path) -> typedefs.ConfigValues:
1616
"""See the Parser.parse_config method."""
1717
config = configparser.ConfigParser()
1818
_ = config.read(file_path)

src/maison/parsers/pyproject.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import toml
66

7-
from maison import types
7+
from maison import typedefs
88

99

1010
class PyprojectParser:
@@ -22,7 +22,7 @@ def __init__(self, package_name: str) -> None:
2222
"""
2323
self._package_name = package_name
2424

25-
def parse_config(self, file_path: pathlib.Path) -> types.ConfigValues:
25+
def parse_config(self, file_path: pathlib.Path) -> typedefs.ConfigValues:
2626
"""See the Parser.parse_config method."""
2727
try:
2828
pyproject_dict = dict(toml.load(file_path))

src/maison/parsers/toml.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import toml
66

7-
from maison import types
7+
from maison import typedefs
88

99

1010
class TomlParser:
@@ -13,7 +13,7 @@ class TomlParser:
1313
Implements the `Parser` protocol
1414
"""
1515

16-
def parse_config(self, file_path: pathlib.Path) -> types.ConfigValues:
16+
def parse_config(self, file_path: pathlib.Path) -> typedefs.ConfigValues:
1717
"""See the Parser.parse_config method."""
1818
try:
1919
return dict(toml.load(file_path))

src/maison/protocols.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
import pathlib
44
import typing
55

6-
from maison import types
6+
from maison import typedefs
77

88

99
class Parser(typing.Protocol):
1010
"""Defines the interface for a parser used to parse a config file."""
1111

12-
def parse_config(self, file_path: pathlib.Path) -> types.ConfigValues:
12+
def parse_config(self, file_path: pathlib.Path) -> typedefs.ConfigValues:
1313
"""Parses a config file.
1414
1515
Args:
@@ -24,7 +24,7 @@ def parse_config(self, file_path: pathlib.Path) -> types.ConfigValues:
2424
class IsSchema(typing.Protocol):
2525
"""Protocol for config schemas."""
2626

27-
def model_dump(self) -> types.ConfigValues:
27+
def model_dump(self) -> typedefs.ConfigValues:
2828
"""Convert the validated config to a dict."""
2929
...
3030

@@ -49,7 +49,7 @@ def get_file_path(
4949
class ConfigParser(typing.Protocol):
5050
"""Defines the interface for a class that parses a config."""
5151

52-
def parse_config(self, file_path: pathlib.Path) -> types.ConfigValues:
52+
def parse_config(self, file_path: pathlib.Path) -> typedefs.ConfigValues:
5353
"""Parse a config.
5454
5555
Args:
@@ -65,8 +65,8 @@ class Validator(typing.Protocol):
6565
"""Defines the interface for a class that validates some config values."""
6666

6767
def validate(
68-
self, values: types.ConfigValues, schema: type[IsSchema]
69-
) -> types.ConfigValues:
68+
self, values: typedefs.ConfigValues, schema: type[IsSchema]
69+
) -> typedefs.ConfigValues:
7070
"""Validate a config.
7171
7272
Args:

src/maison/service.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from collections.abc import Iterable
66

77
from maison import protocols
8-
from maison import types
8+
from maison import typedefs
99
from maison import utils
1010

1111

@@ -53,7 +53,7 @@ def get_config_values(
5353
self,
5454
config_file_paths: Iterable[pathlib.Path],
5555
merge_configs: bool,
56-
) -> types.ConfigValues:
56+
) -> typedefs.ConfigValues:
5757
"""Get the values from config files.
5858
5959
Args:
@@ -64,7 +64,7 @@ def get_config_values(
6464
Returns:
6565
The values from the config file(s)
6666
"""
67-
config_values: types.ConfigValues = {}
67+
config_values: typedefs.ConfigValues = {}
6868

6969
for path in config_file_paths:
7070
parsed_config = self.config_parser.parse_config(path)
@@ -76,8 +76,8 @@ def get_config_values(
7676
return config_values
7777

7878
def validate_config(
79-
self, values: types.ConfigValues, schema: type[protocols.IsSchema]
80-
) -> types.ConfigValues:
79+
self, values: typedefs.ConfigValues, schema: type[protocols.IsSchema]
80+
) -> typedefs.ConfigValues:
8181
"""Validate config values against a schema.
8282
8383
Args:

src/maison/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
"""Module to hold various utils."""
22

3-
from maison import types
3+
from maison import typedefs
44

55

66
def deep_merge(
7-
destination: types.ConfigValues, source: types.ConfigValues
8-
) -> types.ConfigValues:
7+
destination: typedefs.ConfigValues, source: typedefs.ConfigValues
8+
) -> typedefs.ConfigValues:
99
"""Recursively updates the destination dictionary.
1010
1111
Usage example:

0 commit comments

Comments
 (0)