bugdantic 0.4.0__tar.gz → 0.4.2__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.
- {bugdantic-0.4.0 → bugdantic-0.4.2}/PKG-INFO +5 -4
- {bugdantic-0.4.0 → bugdantic-0.4.2}/bugdantic/bugzilla.py +16 -12
- {bugdantic-0.4.0 → bugdantic-0.4.2}/bugdantic/userstory.py +4 -4
- {bugdantic-0.4.0 → bugdantic-0.4.2}/bugdantic.egg-info/PKG-INFO +5 -4
- {bugdantic-0.4.0 → bugdantic-0.4.2}/bugdantic.egg-info/requires.txt +4 -3
- {bugdantic-0.4.0 → bugdantic-0.4.2}/pyproject.toml +11 -4
- {bugdantic-0.4.0 → bugdantic-0.4.2}/test/test_bugzilla.py +12 -1
- {bugdantic-0.4.0 → bugdantic-0.4.2}/LICENSE +0 -0
- {bugdantic-0.4.0 → bugdantic-0.4.2}/README.md +0 -0
- {bugdantic-0.4.0 → bugdantic-0.4.2}/bugdantic/__init__.py +0 -0
- {bugdantic-0.4.0 → bugdantic-0.4.2}/bugdantic/py.typed +0 -0
- {bugdantic-0.4.0 → bugdantic-0.4.2}/bugdantic.egg-info/SOURCES.txt +0 -0
- {bugdantic-0.4.0 → bugdantic-0.4.2}/bugdantic.egg-info/dependency_links.txt +0 -0
- {bugdantic-0.4.0 → bugdantic-0.4.2}/bugdantic.egg-info/top_level.txt +0 -0
- {bugdantic-0.4.0 → bugdantic-0.4.2}/setup.cfg +0 -0
- {bugdantic-0.4.0 → bugdantic-0.4.2}/test/test_userstory.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: bugdantic
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.2
|
|
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
|
|
@@ -11,8 +11,9 @@ License-File: LICENSE
|
|
|
11
11
|
Requires-Dist: httpx[http2]>=0.28.1
|
|
12
12
|
Requires-Dist: pydantic>=2.11.3
|
|
13
13
|
Provides-Extra: test
|
|
14
|
-
Requires-Dist: mypy==
|
|
15
|
-
Requires-Dist: ruff==0.
|
|
16
|
-
Requires-Dist: pytest==
|
|
14
|
+
Requires-Dist: mypy==2.3.0; extra == "test"
|
|
15
|
+
Requires-Dist: ruff==0.16.2; extra == "test"
|
|
16
|
+
Requires-Dist: pytest==9.1.1; extra == "test"
|
|
17
17
|
Requires-Dist: pytest-ruff==0.5; extra == "test"
|
|
18
|
+
Requires-Dist: ty==0.0.71; extra == "test"
|
|
18
19
|
Dynamic: license-file
|
|
@@ -2,15 +2,13 @@ import base64
|
|
|
2
2
|
import enum
|
|
3
3
|
import json
|
|
4
4
|
import logging
|
|
5
|
+
from collections.abc import Mapping, MutableMapping, Sequence
|
|
5
6
|
from dataclasses import dataclass
|
|
6
7
|
from datetime import datetime
|
|
7
8
|
from typing import (
|
|
8
9
|
Any,
|
|
9
10
|
Generic,
|
|
10
|
-
Mapping,
|
|
11
|
-
MutableMapping,
|
|
12
11
|
Optional,
|
|
13
|
-
Sequence,
|
|
14
12
|
Self,
|
|
15
13
|
TypeVar,
|
|
16
14
|
cast,
|
|
@@ -454,6 +452,13 @@ def bug_search_model(bug_type: type[BugType]) -> type[BugSearchGeneric[BugType]]
|
|
|
454
452
|
)
|
|
455
453
|
|
|
456
454
|
|
|
455
|
+
def model_field_names(model: type[BaseModel]) -> list[str]:
|
|
456
|
+
return [
|
|
457
|
+
field.alias if field.alias else name
|
|
458
|
+
for name, field in model.model_fields.items()
|
|
459
|
+
]
|
|
460
|
+
|
|
461
|
+
|
|
457
462
|
class Bugzilla:
|
|
458
463
|
def __init__(self, config: BugzillaConfig):
|
|
459
464
|
self.config = config
|
|
@@ -488,8 +493,7 @@ class Bugzilla:
|
|
|
488
493
|
if exclude_fields is not None:
|
|
489
494
|
params["exclude_fields"] = ",".join(exclude_fields)
|
|
490
495
|
|
|
491
|
-
|
|
492
|
-
path = path[1:]
|
|
496
|
+
path = path.removeprefix("/")
|
|
493
497
|
|
|
494
498
|
url = urljoin(self.config.base_url, f"/rest/{path}")
|
|
495
499
|
|
|
@@ -508,13 +512,13 @@ class Bugzilla:
|
|
|
508
512
|
assert response is not None
|
|
509
513
|
try:
|
|
510
514
|
response.raise_for_status()
|
|
511
|
-
except Exception
|
|
515
|
+
except Exception:
|
|
512
516
|
msg = "Request failed"
|
|
513
517
|
json_resp = response.json()
|
|
514
518
|
if json_resp:
|
|
515
519
|
msg += f"\n{json_resp.get('message')}"
|
|
516
520
|
logging.error(msg)
|
|
517
|
-
raise
|
|
521
|
+
raise
|
|
518
522
|
return response.json()
|
|
519
523
|
else:
|
|
520
524
|
logging.info(f"""Not updating, would send {method} request to {path} with body:
|
|
@@ -558,7 +562,7 @@ class Bugzilla:
|
|
|
558
562
|
return self._bug(bug_id, Bug, include_fields)
|
|
559
563
|
|
|
560
564
|
def bug_as(self, bug_id: int, bug_type: type[BugType]) -> Optional[BugType]:
|
|
561
|
-
include_fields =
|
|
565
|
+
include_fields = model_field_names(bug_type)
|
|
562
566
|
return self._bug(bug_id, bug_type, include_fields)
|
|
563
567
|
|
|
564
568
|
def bugs(
|
|
@@ -585,9 +589,9 @@ class Bugzilla:
|
|
|
585
589
|
bug_ids: Sequence[int],
|
|
586
590
|
bug_type: type[BugType],
|
|
587
591
|
page_size: int = 100,
|
|
588
|
-
) -> list[
|
|
592
|
+
) -> list[BugType]:
|
|
589
593
|
"""Get multiple bugs specified by id"""
|
|
590
|
-
results: list[
|
|
594
|
+
results: list[BugType] = []
|
|
591
595
|
for bug_ids_chunk in [
|
|
592
596
|
bug_ids[n : n + page_size] for n in range(0, len(bug_ids), page_size)
|
|
593
597
|
]:
|
|
@@ -668,8 +672,8 @@ class Bugzilla:
|
|
|
668
672
|
|
|
669
673
|
def search_as(
|
|
670
674
|
self, query: QueryParams, bug_type: type[BugType], page_size: int = 100
|
|
671
|
-
):
|
|
672
|
-
include_fields =
|
|
675
|
+
) -> list[BugType]:
|
|
676
|
+
include_fields = model_field_names(bug_type)
|
|
673
677
|
return self._search(bug_type, query, include_fields, page_size)
|
|
674
678
|
|
|
675
679
|
def update_bugs(
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"""Utility functions for working with cf_user_story fields that
|
|
2
2
|
are used to store key: value pair data"""
|
|
3
3
|
|
|
4
|
+
import re
|
|
4
5
|
from collections import defaultdict
|
|
5
|
-
from
|
|
6
|
+
from collections.abc import Iterator, Mapping
|
|
6
7
|
from dataclasses import dataclass
|
|
7
|
-
|
|
8
|
-
import
|
|
9
|
-
from typing import Iterator, Optional, Mapping, Self
|
|
8
|
+
from enum import IntEnum
|
|
9
|
+
from typing import Optional, Self
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
def parse(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: bugdantic
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.2
|
|
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
|
|
@@ -11,8 +11,9 @@ License-File: LICENSE
|
|
|
11
11
|
Requires-Dist: httpx[http2]>=0.28.1
|
|
12
12
|
Requires-Dist: pydantic>=2.11.3
|
|
13
13
|
Provides-Extra: test
|
|
14
|
-
Requires-Dist: mypy==
|
|
15
|
-
Requires-Dist: ruff==0.
|
|
16
|
-
Requires-Dist: pytest==
|
|
14
|
+
Requires-Dist: mypy==2.3.0; extra == "test"
|
|
15
|
+
Requires-Dist: ruff==0.16.2; extra == "test"
|
|
16
|
+
Requires-Dist: pytest==9.1.1; extra == "test"
|
|
17
17
|
Requires-Dist: pytest-ruff==0.5; extra == "test"
|
|
18
|
+
Requires-Dist: ty==0.0.71; extra == "test"
|
|
18
19
|
Dynamic: license-file
|
|
@@ -5,7 +5,7 @@ authors = [
|
|
|
5
5
|
{name = "James Graham", email = "james@hoppipolla.co.uk"}
|
|
6
6
|
]
|
|
7
7
|
|
|
8
|
-
version = "0.4.
|
|
8
|
+
version = "0.4.2"
|
|
9
9
|
requires-python = ">=3.11"
|
|
10
10
|
license = "MPL-2.0"
|
|
11
11
|
classifiers = [
|
|
@@ -20,8 +20,15 @@ dependencies = [
|
|
|
20
20
|
|
|
21
21
|
[project.optional-dependencies]
|
|
22
22
|
test = [
|
|
23
|
-
"mypy==
|
|
24
|
-
"ruff==0.
|
|
25
|
-
"pytest==
|
|
23
|
+
"mypy==2.3.0",
|
|
24
|
+
"ruff==0.16.2",
|
|
25
|
+
"pytest==9.1.1",
|
|
26
26
|
"pytest-ruff==0.5",
|
|
27
|
+
"ty==0.0.71",
|
|
27
28
|
]
|
|
29
|
+
|
|
30
|
+
[tool.mypy]
|
|
31
|
+
disallow_untyped_defs = true
|
|
32
|
+
|
|
33
|
+
[tool.ruff.lint]
|
|
34
|
+
ignore = ["UP045", "LOG015"]
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import pytest
|
|
2
|
-
from pydantic import BaseModel
|
|
2
|
+
from pydantic import BaseModel, Field
|
|
3
3
|
|
|
4
4
|
from bugdantic import Bugzilla, BugzillaConfig
|
|
5
5
|
from bugdantic.bugzilla import BugComment
|
|
@@ -69,3 +69,14 @@ def test_search_as(bugzilla):
|
|
|
69
69
|
assert isinstance(bug, BugData)
|
|
70
70
|
assert bug.id == expected_id
|
|
71
71
|
assert isinstance(bug.comments, list)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def test_bug_as_alias(bugzilla):
|
|
75
|
+
class BugData(BaseModel):
|
|
76
|
+
id: int
|
|
77
|
+
user_story: str = Field(alias="cf_user_story")
|
|
78
|
+
|
|
79
|
+
result = bugzilla.bug_as(975444, BugData)
|
|
80
|
+
assert isinstance(result, BugData)
|
|
81
|
+
assert result.id == 975444
|
|
82
|
+
assert result.user_story is not None
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|