Skip to content

Commit

Permalink
Merge pull request #289 from networktocode/release/2.6.1
Browse files Browse the repository at this point in the history
Release/2.6.1
  • Loading branch information
glennmatthews authored Jun 4, 2024
2 parents 10acd84 + 941fa9d commit 30acf33
Show file tree
Hide file tree
Showing 6 changed files with 331 additions and 265 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## v2.6.1 - 2024-06-04

### Fixed

- [#288](https://github.com/networktocode/circuit-maintenance-parser/pull/288) - Fixed exceptions under Pydantic 1.x.

### Dependencies

- [#286](https://github.com/networktocode/circuit-maintenance-parser/pull/286) - Added support for `lxml` 5.x.

## v2.6.0 - 2024-04-04

### Added
Expand Down
13 changes: 10 additions & 3 deletions circuit_maintenance_parser/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,13 @@ class CircuitImpact(BaseModel, extra="forbid"):
>>> CircuitImpact(
... circuit_id="1234",
... impact="wrong impact"
... )
... ) # doctest:+ELLIPSIS
Traceback (most recent call last):
...
pydantic_core._pydantic_core.ValidationError: 1 validation error for CircuitImpact
impact
Input should be 'NO-IMPACT', 'REDUCED-REDUNDANCY', 'DEGRADED' or 'OUTAGE' [type=enum, input_value='wrong impact', input_type=str]
...
"""

circuit_id: StrictStr
Expand Down Expand Up @@ -203,7 +204,10 @@ def validate_empty_strings(cls, value):
@classmethod
def validate_empty_circuits(cls, value, values):
"""Validate non-cancel notifications have a populated circuit list."""
values = values.data
try:
values = values.data # pydantic 2.x
except AttributeError: # pydantic 1.x
pass
if len(value) < 1 and values["status"] not in (Status.CANCELLED, Status.COMPLETED):
raise ValueError("At least one circuit has to be included in the maintenance")
return value
Expand All @@ -212,7 +216,10 @@ def validate_empty_circuits(cls, value, values):
@classmethod
def validate_end_time(cls, end, values):
"""Validate that End time happens after Start time."""
values = values.data
try:
values = values.data # pydantic 2.x
except AttributeError: # pydantic 1.x
pass
if "start" not in values:
raise ValueError("Start time is a mandatory attribute.")
start = values["start"]
Expand Down
2 changes: 1 addition & 1 deletion circuit_maintenance_parser/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def get_data_types(cls) -> List[str]:
return cls._data_types.get_default()
except AttributeError:
# TODO: This exception handling is required for Pydantic 1.x compatibility. To be removed when the dependency is deprecated.
return cls._data_types
return cls()._data_types

@classmethod
def get_name(cls) -> str:
Expand Down
8 changes: 4 additions & 4 deletions circuit_maintenance_parser/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def get_default_organizer(cls) -> str:
return cls._default_organizer.get_default() # type: ignore
except AttributeError:
# TODO: This exception handling is required for Pydantic 1.x compatibility. To be removed when the dependency is deprecated.
return cls._default_organizer
return cls()._default_organizer

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

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

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

@classmethod
def get_extended_data(cls):
Expand Down
Loading

0 comments on commit 30acf33

Please sign in to comment.