Skip to content

Commit 30acf33

Browse files
Merge pull request #289 from networktocode/release/2.6.1
Release/2.6.1
2 parents 10acd84 + 941fa9d commit 30acf33

File tree

6 files changed

+331
-265
lines changed

6 files changed

+331
-265
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Changelog
22

3+
## v2.6.1 - 2024-06-04
4+
5+
### Fixed
6+
7+
- [#288](https://github.com/networktocode/circuit-maintenance-parser/pull/288) - Fixed exceptions under Pydantic 1.x.
8+
9+
### Dependencies
10+
11+
- [#286](https://github.com/networktocode/circuit-maintenance-parser/pull/286) - Added support for `lxml` 5.x.
12+
313
## v2.6.0 - 2024-04-04
414

515
### Added

circuit_maintenance_parser/output.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,13 @@ class CircuitImpact(BaseModel, extra="forbid"):
7777
>>> CircuitImpact(
7878
... circuit_id="1234",
7979
... impact="wrong impact"
80-
... )
80+
... ) # doctest:+ELLIPSIS
8181
Traceback (most recent call last):
8282
...
8383
pydantic_core._pydantic_core.ValidationError: 1 validation error for CircuitImpact
8484
impact
8585
Input should be 'NO-IMPACT', 'REDUCED-REDUNDANCY', 'DEGRADED' or 'OUTAGE' [type=enum, input_value='wrong impact', input_type=str]
86+
...
8687
"""
8788

8889
circuit_id: StrictStr
@@ -203,7 +204,10 @@ def validate_empty_strings(cls, value):
203204
@classmethod
204205
def validate_empty_circuits(cls, value, values):
205206
"""Validate non-cancel notifications have a populated circuit list."""
206-
values = values.data
207+
try:
208+
values = values.data # pydantic 2.x
209+
except AttributeError: # pydantic 1.x
210+
pass
207211
if len(value) < 1 and values["status"] not in (Status.CANCELLED, Status.COMPLETED):
208212
raise ValueError("At least one circuit has to be included in the maintenance")
209213
return value
@@ -212,7 +216,10 @@ def validate_empty_circuits(cls, value, values):
212216
@classmethod
213217
def validate_end_time(cls, end, values):
214218
"""Validate that End time happens after Start time."""
215-
values = values.data
219+
try:
220+
values = values.data # pydantic 2.x
221+
except AttributeError: # pydantic 1.x
222+
pass
216223
if "start" not in values:
217224
raise ValueError("Start time is a mandatory attribute.")
218225
start = values["start"]

circuit_maintenance_parser/parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def get_data_types(cls) -> List[str]:
4646
return cls._data_types.get_default()
4747
except AttributeError:
4848
# TODO: This exception handling is required for Pydantic 1.x compatibility. To be removed when the dependency is deprecated.
49-
return cls._data_types
49+
return cls()._data_types
5050

5151
@classmethod
5252
def get_name(cls) -> str:

circuit_maintenance_parser/provider.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def get_default_organizer(cls) -> str:
155155
return cls._default_organizer.get_default() # type: ignore
156156
except AttributeError:
157157
# TODO: This exception handling is required for Pydantic 1.x compatibility. To be removed when the dependency is deprecated.
158-
return cls._default_organizer
158+
return cls()._default_organizer
159159

160160
@classmethod
161161
def get_default_processors(cls) -> List[GenericProcessor]:
@@ -164,7 +164,7 @@ def get_default_processors(cls) -> List[GenericProcessor]:
164164
return cls._processors.get_default() # type: ignore
165165
except AttributeError:
166166
# TODO: This exception handling is required for Pydantic 1.x compatibility. To be removed when the dependency is deprecated.
167-
return cls._processors
167+
return cls()._processors
168168

169169
@classmethod
170170
def get_default_include_filters(cls) -> Dict[str, List[str]]:
@@ -173,7 +173,7 @@ def get_default_include_filters(cls) -> Dict[str, List[str]]:
173173
return cls._include_filter.get_default() # type: ignore
174174
except AttributeError:
175175
# TODO: This exception handling is required for Pydantic 1.x compatibility. To be removed when the dependency is deprecated.
176-
return cls._include_filter
176+
return cls()._include_filter
177177

178178
@classmethod
179179
def get_default_exclude_filters(cls) -> Dict[str, List[str]]:
@@ -182,7 +182,7 @@ def get_default_exclude_filters(cls) -> Dict[str, List[str]]:
182182
return cls._exclude_filter.get_default() # type: ignore
183183
except AttributeError:
184184
# TODO: This exception handling is required for Pydantic 1.x compatibility. To be removed when the dependency is deprecated.
185-
return cls._exclude_filter
185+
return cls()._exclude_filter
186186

187187
@classmethod
188188
def get_extended_data(cls):

0 commit comments

Comments
 (0)