diff --git a/pkgs/development/python-modules/datamodel-code-generator/default.nix b/pkgs/development/python-modules/datamodel-code-generator/default.nix index e542fbc0acbb..875cb53d382d 100644 --- a/pkgs/development/python-modules/datamodel-code-generator/default.nix +++ b/pkgs/development/python-modules/datamodel-code-generator/default.nix @@ -1,59 +1,70 @@ { lib, - argcomplete, - black, buildPythonPackage, - email-validator, fetchFromGitHub, - genson, - graphql-core, - grpcio-tools, + + # build-system hatch-vcs, hatchling, + + # dependencies + argcomplete, + black, + genson, + inflect, + isort, + jinja2, + packaging, + pydantic, + pyyaml, + + # optional-dependencies + # debug: + pysnooper, + # graphql: + graphql-core, + # http: httpx, + # protobuf: + grpcio-tools, + # ruff: + ruff, + # validation: + openapi-spec-validator, + prance, + # watch: + watchfiles, + + # tests + email-validator, hypothesis, hypothesis-jsonschema, - inflect, inline-snapshot, - isort, jsonschema, msgspec, - jinja2, - openapi-spec-validator, - packaging, - prance, - ruff, - pydantic, - pysnooper, pytest-mock, pytest-timeout, pytest-xdist, pytestCheckHook, - pyyaml, time-machine, - watchfiles, }: -buildPythonPackage rec { +buildPythonPackage (finalAttrs: { pname = "datamodel-code-generator"; version = "0.71.0"; pyproject = true; + __structuredAttrs = true; src = fetchFromGitHub { owner = "koxudaxi"; repo = "datamodel-code-generator"; - tag = version; + tag = finalAttrs.version; hash = "sha256-0vh/iynZzmMzvdUXNScb+JWANdSrzPLT1qt+jyKleg4="; }; - pythonRelaxDeps = [ - "inflect" - "isort" - ]; - build-system = [ - hatchling hatch-vcs + hatchling ]; dependencies = [ @@ -68,8 +79,7 @@ buildPythonPackage rec { pyyaml ]; - optional-dependencies = { - all = lib.concatAttrValues (lib.removeAttrs optional-dependencies [ "all" ]); + optional-dependencies = lib.fix (self: { debug = [ pysnooper ]; graphql = [ graphql-core ]; http = [ httpx ]; @@ -82,13 +92,13 @@ buildPythonPackage rec { watch = [ watchfiles ]; - }; + }); nativeCheckInputs = [ email-validator - inline-snapshot hypothesis hypothesis-jsonschema + inline-snapshot jsonschema msgspec pytest-mock @@ -97,15 +107,20 @@ buildPythonPackage rec { pytestCheckHook time-machine ] - ++ optional-dependencies.all; - - pytestFlags = [ - "--maxfail=2" - ]; + ++ lib.concatAttrValues finalAttrs.passthru.optional-dependencies; disabledTests = [ # remote testing, name resolution failure. "test_openapi_parser_parse_remote_ref" + + # ruff formatting changed, causing errors such as + # Failed: Output mismatch + # AssertionError: Content mismatch for ... + "test_no_use_type_checking_imports" + "test_ruff_batch_formatting_directory" + "test_ruff_check_and_format_combined" + "test_ruff_check_only" + "test_type_checking_imports_default_to_runtime_imports_for_modular_pydantic_ruff" ]; pythonImportsCheck = [ "datamodel_code_generator" ]; @@ -113,9 +128,9 @@ buildPythonPackage rec { meta = { description = "Pydantic model and dataclasses.dataclass generator for easy conversion of JSON, OpenAPI, JSON Schema, and YAML data sources"; homepage = "https://github.com/koxudaxi/datamodel-code-generator"; - changelog = "https://github.com/koxudaxi/datamodel-code-generator/releases/tag/${src.tag}"; + changelog = "https://github.com/koxudaxi/datamodel-code-generator/releases/tag/${finalAttrs.src.tag}"; license = lib.licenses.mit; maintainers = with lib.maintainers; [ tochiaha ]; mainProgram = "datamodel-code-generator"; }; -} +})