Skip to content

Commit

Permalink
Merge branch 'v4.0.x' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhozic committed Feb 4, 2024
2 parents d703ea5 + 1341f33 commit c68a11a
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 5 deletions.
7 changes: 7 additions & 0 deletions docs/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ Glossary
Releases
---------------------

v4.0.4
=====================
- Fixed automatic responder's not being removable over a remote connection.
- Fixed casting error when trying to update objects with ``Literal`` parameters.
- Other GUI fixes (from tkclasswiz library)


v4.0.3
====================
- Fixed object editing window saving to an incorrect index (and removing other objects).
Expand Down
2 changes: 1 addition & 1 deletion src/daf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import warnings


VERSION = "4.0.3"
VERSION = "4.0.4"


if sys.version_info.minor == 12 and sys.version_info.major == 3:
Expand Down
13 changes: 12 additions & 1 deletion src/daf/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,18 @@ def import_class(path: str):
"custom_decoder": lambda data: re.compile(data["pattern"], data.get("flags", 0))
},
responder.DMResponder: {
"attrs": ["condition", "action", "constraints"]
"attrs": attributes.get_all_slots(responder.DMResponder),
"attrs_restore": {
"client": None,
"event_ctrl": None
}
},
responder.GuildResponder: {
"attrs": attributes.get_all_slots(responder.GuildResponder),
"attrs_restore": {
"client": None,
"event_ctrl": None
}
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/daf/misc/instance_track.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from weakref import WeakValueDictionary
from functools import wraps

from .attributes import get_all_slots


__all__ = (
"get_by_id",
Expand Down Expand Up @@ -59,7 +61,7 @@ def track_id(cls):
"""
@wraps(cls, updated=[])
class TrackedClass(cls):
if hasattr(cls, "__slots__") and cls.__slots__: # Don't break classes without slots
if hasattr(cls, "__slots__") and get_all_slots(cls): # Don't break classes without slots
__slots__ = ["_daf_id", "_tracked_allow_remote"]
if not hasattr(cls, "__weakref__"):
__slots__.append('__weakref__')
Expand Down
8 changes: 8 additions & 0 deletions src/daf/responder/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ class ResponderBase(ABC):
before performing an action.
All of the constraints inside the ``constraints`` list need to be fulfilled.
"""
__slots__ = (
"condition",
"constraints",
"action",
"event_ctrl",
"client",
)

def __init__(
self,
condition: BaseLogic,
Expand Down
1 change: 1 addition & 0 deletions src/daf/responder/dmresponder.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
@doc_category("Auto responder", path="responder")
class DMResponder(ResponderBase):
__doc__ = "DM responder implementation. " + ResponderBase.__doc__
__slots__ = tuple()

@typechecked
def __init__(
Expand Down
1 change: 1 addition & 0 deletions src/daf/responder/guildresponder.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
@doc_category("Auto responder", path="responder")
class GuildResponder(ResponderBase):
__doc__ = "Guild responder implementation. " + ResponderBase.__doc__
__slots__ = tuple()

@typechecked
def __init__(
Expand Down
11 changes: 10 additions & 1 deletion src/daf_gui/tod_extensions/extra_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,16 @@ async def update():
values = {}
for k, v in frame.get_gui_data().items():
if isinstance(v, str):
v = frame.cast_type(v, frame._map[k][1])
types_ = frame._map[k][1]
try:
frame.cast_type(v, types_)
except TypeError as exc:
# Perhaps it's a valid literal:
literal_types = frame.filter_literals(types_)
if not literal_types:
raise

frame.check_literals(v, literal_types)

values[k] = convert_to_objects(v)

Expand Down
2 changes: 1 addition & 1 deletion src/daf_gui/tod_extensions/method_execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
},
daf.ACCOUNT.remove_responder: {
# ACCOUNT.servers
"responder_to_remove": lambda old_info: old_info.data["responders"]
"resp": lambda old_info: old_info.data["responders"]
}
}

Expand Down

0 comments on commit c68a11a

Please sign in to comment.