Skip to content

Commit

Permalink
Merge pull request #9 from magicalpuffin/tooling-update
Browse files Browse the repository at this point in the history
Tooling update
  • Loading branch information
magicalpuffin authored Aug 2, 2024
2 parents 74cc2ad + 2fb8192 commit 337e2c9
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 54 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.hatch
.obsidian
.vscode

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
7 changes: 0 additions & 7 deletions .vscode/settings.json

This file was deleted.

61 changes: 18 additions & 43 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,51 +31,32 @@ Issues = "https://github.com/magicalpuffin/pandas-to-pydantic/issues"
Source = "https://github.com/magicalpuffin/pandas-to-pydantic"


[tool.pyright]
venvPath = "./.hatch/"
venv = "pandas-to-pydantic"

[tool.hatch.version]
path = "src/pandas_to_pydantic/__about__.py"

[tool.hatch.envs.default]
dependencies = [
"coverage[toml]>=6.5",
"pytest",
]
dependencies = ["coverage[toml]>=6.5", "pytest", "pandas-stubs"]
[tool.hatch.envs.default.scripts]
test = "pytest {args:tests}"
test-cov = "coverage run -m pytest {args:tests}"
cov-report = [
"- coverage combine",
"coverage report",
]
cov = [
"test-cov",
"cov-report",
]
test = "pytest {args:tests}"
test-cov = "coverage run -m pytest {args:tests}"
cov-report = ["- coverage combine", "coverage report"]
cov = ["test-cov", "cov-report"]

[[tool.hatch.envs.all.matrix]]
python = ["3.9", "3.10", "3.11", "3.12"]

[tool.hatch.envs.lint]
detached = true
dependencies = [
"black>=23.1.0",
"mypy>=1.0.0",
"ruff>=0.0.243",
]
detached = true
dependencies = ["black>=23.1.0", "mypy>=1.0.0", "ruff>=0.0.243"]
[tool.hatch.envs.lint.scripts]
typing = "mypy --install-types --non-interactive {args:src/pandas_to_pydantic tests}"
style = [
"ruff {args:.}",
"black --check --diff {args:.}",
]
fmt = [
"black {args:.}",
"ruff --fix {args:.}",
"style",
]
all = [
"style",
"typing",
]
style = ["ruff {args:.}", "black --check --diff {args:.}"]
fmt = ["black {args:.}", "ruff --fix {args:.}", "style"]
all = ["style", "typing"]

[tool.black]
target-version = ["py37"]
Expand Down Expand Up @@ -145,11 +126,9 @@ ban-relative-imports = "all"

[tool.coverage.run]
source_pkgs = ["pandas_to_pydantic", "tests"]
branch = true
parallel = true
omit = [
"src/pandas_to_pydantic/__about__.py",
]
branch = true
parallel = true
omit = ["src/pandas_to_pydantic/__about__.py"]

[tool.coverage.paths]
pandas_to_pydantic = [
Expand All @@ -159,8 +138,4 @@ pandas_to_pydantic = [
tests = ["tests", "*/pandas-to-pydantic/tests"]

[tool.coverage.report]
exclude_lines = [
"no cov",
"if __name__ == .__main__.:",
"if TYPE_CHECKING:",
]
exclude_lines = ["no cov", "if __name__ == .__main__.:", "if TYPE_CHECKING:"]
2 changes: 1 addition & 1 deletion src/pandas_to_pydantic/__about__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = "0.1.2"
VERSION = "0.1.3"
6 changes: 3 additions & 3 deletions src/pandas_to_pydantic/to_pydantic.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,19 @@ def serialize_dataframe(data: pd.DataFrame, model_columns: ModelColumns) -> list
return new_list


def get_root_list(serialize_data: list[Union[dict, ModelMetaclass]], model: ModelMetaclass) -> RootModel:
def get_root_list(serialize_data: Union[list[dict], list[ModelMetaclass]], model: ModelMetaclass) -> RootModel:
"""
Converts json-like data into a pydantic list RootModel
Args:
serialize_data (list[Union[dict, ModelMetaclass]]): data in json-like structure or list of pydantic objects
serialize_data (Union[list[dict], list[ModelMetaclass]]): data in json-like structure or list of pydantic object
model (ModelMetaclass): pydantic model
Returns:
RootModel: list of pydantic model set to the input data
"""
root_list_model = RootModel[list[model]]
root_list = root_list_model(serialize_data)
root_list = root_list_model(serialize_data) # type: ignore

return root_list

Expand Down
2 changes: 2 additions & 0 deletions taplo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[formatting]
align_entries = true

0 comments on commit 337e2c9

Please sign in to comment.