Skip to content

simplify test setup#503

Merged
fricklerhandwerk merged 3 commits intoNixOS:mainfrom
fricklerhandwerk:refactor-tests
Apr 28, 2025
Merged

simplify test setup#503
fricklerhandwerk merged 3 commits intoNixOS:mainfrom
fricklerhandwerk:refactor-tests

Conversation

@fricklerhandwerk
Copy link
Collaborator

@fricklerhandwerk fricklerhandwerk commented Apr 24, 2025

No description provided.

@fricklerhandwerk fricklerhandwerk force-pushed the refactor-tests branch 2 times, most recently from 65822ea to c3ab74e Compare April 24, 2025 10:43
fricklerhandwerk and others added 3 commits April 24, 2025 23:55
Advantages:
- Explicit declaration of what is expected

  A default value alone doesn't explain which shape a setting needs to take.

- Rich type library

  Pydantic offers lots of expressive, convenient types out of the box,
  such as "writeable directory".

- Type checking before startup

  Instead of running into runtime issues, all settings are validated
  before the application can do anything.

- Transparent handling of structured data via JSON

  Settings can be arbitrarily complex data, which needs to be encoded to
  strings anyway when passing to the application.

  With Pydantic we can go directly from Nix attrsets as JSON in an
  environment variable, instead of taking the detour via Python expressions.
  Note though that it's inconvenient to use plain attrsets converted to
  environment variables, since Nix will translate `false` to empty string
  (which requires extra code to handle that on the Pydantic side),
  and nested structures, however rare, would need to be handled manually anyway.
Make explicit that this needs to be set deliberately:
Enabling or disabling it by default will break either tests or
production at runtime if the caller doesn't know the setting exists.
Making it required will at least inform the caller early on that there is a decision to be made.

This fixes the VM tests (and showcases how cool `pydantic-settings` is).
@fricklerhandwerk fricklerhandwerk marked this pull request as ready for review April 24, 2025 22:39
@fricklerhandwerk fricklerhandwerk merged commit bb660b9 into NixOS:main Apr 28, 2025
4 checks passed
@fricklerhandwerk
Copy link
Collaborator Author

Working towards #464

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants