• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

microsoft / botbuilder-python / 372200

11 Oct 2023 04:18PM UTC coverage: 67.069% (-2.6%) from 69.649%
372200

push

python-ci

web-flow
Python 3.11 Compatibility (#2022)

* make updates to run tests with 3.11

* run black

* Update botbuilder-python-ci.yml

* update azure devtools

* remove `azure-devtools` due to it being archived

* remove deprecation warning

* lint ignore test files

* ignore tests folder entirely

* Update .pylintrc

* Update .pylintrc

* Update .pylintrc

* only fail on errors

* Update botbuilder-python-ci.yml

* fixes for lint

* test update pylint version

* remove python 3.11 matrix (to be added in separate PR)

10 of 10 new or added lines in 7 files covered. (100.0%)

8998 of 13416 relevant lines covered (67.07%)

0.67 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

87.5
/libraries/botbuilder-dialogs/botbuilder/dialogs/memory/scopes/class_memory_scope.py
1
# Copyright (c) Microsoft Corporation. All rights reserved.
2
# Licensed under the MIT License.
3

4
from collections import namedtuple
2✔
5

6
from botbuilder.dialogs.memory import scope_path
2✔
7

8
from .memory_scope import MemoryScope
2✔
9

10

11
class ClassMemoryScope(MemoryScope):
2✔
12
    def __init__(self):
2✔
13
        super().__init__(scope_path.SETTINGS, include_in_snapshot=False)
2✔
14

15
    def get_memory(self, dialog_context: "DialogContext") -> object:
2✔
16
        if not dialog_context:
2✔
17
            raise TypeError(f"Expecting: DialogContext, but received None")
×
18

19
        # if active dialog is a container dialog then "dialogclass" binds to it.
20
        if dialog_context.active_dialog:
2✔
21
            dialog = dialog_context.find_dialog_sync(dialog_context.active_dialog.id)
2✔
22
            if dialog:
2✔
23
                return ClassMemoryScope._bind_to_dialog_context(dialog, dialog_context)
2✔
24

25
        return None
×
26

27
    def set_memory(self, dialog_context: "DialogContext", memory: object):
2✔
28
        raise Exception(
2✔
29
            f"{self.__class__.__name__}.set_memory not supported (read only)"
30
        )
31

32
    @staticmethod
2✔
33
    def _bind_to_dialog_context(obj, dialog_context: "DialogContext") -> object:
2✔
34
        clone = {}
2✔
35
        for prop in dir(obj):
2✔
36
            # don't process double underscore attributes
37
            if prop[:1] != "_":
2✔
38
                prop_value = getattr(obj, prop)
2✔
39
                if not callable(prop_value):
2✔
40
                    # the only objects
41
                    if hasattr(prop_value, "try_get_value"):
2✔
42
                        clone[prop] = prop_value.try_get_value(dialog_context.state)
2✔
43
                    elif hasattr(prop_value, "__dict__") and not isinstance(
2✔
44
                        prop_value, type(prop_value)
45
                    ):
46
                        clone[prop] = ClassMemoryScope._bind_to_dialog_context(
×
47
                            prop_value, dialog_context
48
                        )
49
                    else:
50
                        clone[prop] = prop_value
2✔
51
        if clone:
2✔
52
            ReadOnlyObject = namedtuple(  # pylint: disable=invalid-name
2✔
53
                "ReadOnlyObject", clone
54
            )
55
            return ReadOnlyObject(**clone)
2✔
56

57
        return None
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc