Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.

Use Literals instead (str, Enum) in models #151

Closed
5 tasks done
JimOverholt opened this issue Apr 25, 2024 · 1 comment
Closed
5 tasks done

Use Literals instead (str, Enum) in models #151

JimOverholt opened this issue Apr 25, 2024 · 1 comment

Comments

@JimOverholt
Copy link
Contributor

Pull Request summary:

Use Literal over the Enums. Justification:

  • Both provides static typing safety ant intellisense (type-hints).
  • (str, Enum) can be problematic as __str__ != __format__ for Enum
  • When instantiating pydantic Field defined as Literal no explicit import of specific Enum is needed

Support Literal when using as_default and as_global (additional optional argument must be provided).

additional minor refactoring:

  • use serialization_alias and validation_alias when applicable
  • replace RefId with Global[UUID]
  • customize public items in catalystwan/models/configuration/feature_profile/sdwan/policy_object/__init__.py and catalystwan/models/policy/__init__.py using PEP-562 features

Description of changes:

[Add more in depth analysis of what changed, provide logs, examples of usage]

Checklist:

  • Make sure to run pre-commit before committing changes
  • Make sure all checks have passed
  • PR description is clear and comprehensive
  • Mentioned the issue that this PR solves (if applicable)
  • Make sure you test the changes
@JimOverholt
Copy link
Contributor Author

This issue was migrated from an old repository: CiscoDevNet/catalystwan#476

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant