diff --git a/.gitignore b/.gitignore index 96b0dc2..50dc5fb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .hatch .obsidian +.vscode # Byte-compiled / optimized / DLL files __pycache__/ diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 9b38853..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "python.testing.pytestArgs": [ - "tests" - ], - "python.testing.unittestEnabled": false, - "python.testing.pytestEnabled": true -} \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 5b82d13..37f8d28 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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"] @@ -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 = [ @@ -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:"] diff --git a/src/pandas_to_pydantic/__about__.py b/src/pandas_to_pydantic/__about__.py index 5411c9a..6d1f1c8 100644 --- a/src/pandas_to_pydantic/__about__.py +++ b/src/pandas_to_pydantic/__about__.py @@ -1 +1 @@ -VERSION = "0.1.2" +VERSION = "0.1.3" diff --git a/src/pandas_to_pydantic/to_pydantic.py b/src/pandas_to_pydantic/to_pydantic.py index 6a99b6e..8df1259 100644 --- a/src/pandas_to_pydantic/to_pydantic.py +++ b/src/pandas_to_pydantic/to_pydantic.py @@ -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 diff --git a/taplo.toml b/taplo.toml new file mode 100644 index 0000000..ac9464c --- /dev/null +++ b/taplo.toml @@ -0,0 +1,2 @@ +[formatting] +align_entries = true