Skip to content

Commit 78a0db6

Browse files
committed
Fixed issues with 'default' attribute not setting correctly, causing failed tests
1 parent e8299c9 commit 78a0db6

File tree

3 files changed

+10
-13
lines changed

3 files changed

+10
-13
lines changed

pyttman/core/entity_parsing/fields.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@ class EntityFieldBase(EntityFieldValueParser, ABC):
2121
datatype if a match is True.
2222
2323
"""
24+
default = None
2425
type_cls = None
2526
identifier_cls = None
2627

2728
def __init__(self,
2829
identifier: Type[Identifier] | None = None,
2930
as_list: bool = False,
31+
default: Any = None,
3032
**kwargs):
3133
"""
3234
:param as_list: If set to True combined with providing 'valid_strings',
@@ -53,7 +55,10 @@ def __init__(self,
5355
f"'type_cls'.")
5456

5557
self.as_list = as_list
56-
super().__init__(identifier=identifier or self.identifier_cls, **kwargs)
58+
_default_arg = default if default is not None else self.default
59+
60+
super().__init__(identifier=identifier or self.identifier_cls,
61+
default=_default_arg, **kwargs)
5762

5863
def convert_value(self, value: Any) -> Any:
5964
"""

pyttman/core/entity_parsing/parsers.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
1-
2-
import abc
31
import typing
4-
from abc import ABC
52
from itertools import zip_longest
6-
from typing import Tuple, Type, Dict, Union
3+
from typing import Type, Dict, Union
74

85
from ordered_set import OrderedSet
96

10-
from core.mixins import PrettyReprMixin
11-
from pyttman.core.exceptions import InvalidPyttmanObjectException
127
from pyttman.core.containers import MessageMixin
138
from pyttman.core.entity_parsing.entity import Entity
149
from pyttman.core.entity_parsing.identifiers import Identifier
10+
from pyttman.core.exceptions import InvalidPyttmanObjectException
11+
from pyttman.core.mixins import PrettyReprMixin
1512

1613

1714
class EntityFieldValueParser(PrettyReprMixin):
@@ -45,7 +42,7 @@ def __init__(self,
4542
self.suffixes = suffixes or tuple()
4643
self.exclude = exclude or tuple()
4744
self.valid_strings = valid_strings or tuple()
48-
self.default = default or None
45+
self.default = default if default is not None else None
4946
self.identifier = identifier
5047
self.span = span
5148
self._properties_for_evaluation = {
@@ -55,7 +52,6 @@ def __init__(self,
5552
"default": self.default,
5653
"valid_strings": self.valid_strings
5754
}
58-
print("SET EXLUDE TO", self.exclude, "ON", self)
5955

6056
def _prepare_params(self):
6157
"""

tests/core/entity_parsing/base.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,6 @@ def test_entity_parser_entity_values(self):
7979

8080
for field_name, expected_value in self.expected_entities.items():
8181
value = self.get_entity_value(field_name)
82-
if self.mock_intent.ignore_in_entities is not None:
83-
for word in self.mock_intent.ignore_in_entities:
84-
self.assertNotIn(word, value)
85-
8682
self.assertEqual(expected_value,
8783
value,
8884
f"\t\tEntityParser test FAILED.\n"

0 commit comments

Comments
 (0)