bugdantic 0.4.3__tar.gz → 0.4.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bugdantic
3
- Version: 0.4.3
3
+ Version: 0.4.4
4
4
  Summary: Bugzilla client based on pydantic
5
5
  Author-email: James Graham <james@hoppipolla.co.uk>
6
6
  License-Expression: MPL-2.0
@@ -455,10 +455,19 @@ def bug_search_model(bug_type: type[BugType]) -> type[BugSearchGeneric[BugType]]
455
455
 
456
456
 
457
457
  def model_field_names(model: type[BaseModel]) -> list[str]:
458
- return [
459
- field.alias if field.alias else name
460
- for name, field in model.model_fields.items()
461
- ]
458
+ field_names = []
459
+ for name, field_obj in model.model_fields.items():
460
+ if field_obj.validation_alias is not None:
461
+ if not isinstance(field_obj.validation_alias, str):
462
+ raise ValueError(
463
+ "Only string values for validation_alias are supported"
464
+ )
465
+ field_names.append(field_obj.validation_alias)
466
+ elif field_obj.alias is not None:
467
+ field_names.append(field_obj.alias)
468
+ else:
469
+ field_names.append(name)
470
+ return field_names
462
471
 
463
472
 
464
473
  class Bugzilla:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bugdantic
3
- Version: 0.4.3
3
+ Version: 0.4.4
4
4
  Summary: Bugzilla client based on pydantic
5
5
  Author-email: James Graham <james@hoppipolla.co.uk>
6
6
  License-Expression: MPL-2.0
@@ -5,7 +5,7 @@ authors = [
5
5
  {name = "James Graham", email = "james@hoppipolla.co.uk"}
6
6
  ]
7
7
 
8
- version = "0.4.3"
8
+ version = "0.4.4"
9
9
  requires-python = ">=3.11"
10
10
  license = "MPL-2.0"
11
11
  classifiers = [
@@ -80,3 +80,16 @@ def test_bug_as_alias(bugzilla):
80
80
  assert isinstance(result, BugData)
81
81
  assert result.id == 975444
82
82
  assert result.user_story is not None
83
+
84
+
85
+ def test_bug_as_validation_alias(bugzilla):
86
+ class BugData(BaseModel):
87
+ id: int
88
+ user_story: str = Field(
89
+ validation_alias="cf_user_story", alias="raw_user_story"
90
+ )
91
+
92
+ result = bugzilla.bug_as(975444, BugData)
93
+ assert isinstance(result, BugData)
94
+ assert result.id == 975444
95
+ assert result.user_story is not None
File without changes
File without changes
File without changes
File without changes