Skip to content

Commit 2c282da

Browse files
author
David Miguel Susano Pinto
committed
microscope.device_server.device: default conf to None.
Using a mutable object such as {} as default can lead to surprises behaviour (see pylint notes for dangerous-default-value / W0102 at https://pylint.pycqa.org/en/stable/user_guide/messages/warning/dangerous-default-value.html ). Indeed, this triggered the issues #211, #212, and #274. So just make the default None and convert to an empty dict.
1 parent 38a1974 commit 2c282da

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

microscope/device_server.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def device(
8181
cls: Callable,
8282
host: str,
8383
port: int,
84-
conf: Mapping[str, Any] = {},
84+
conf: Optional[Mapping[str, Any]] = None,
8585
uid: Optional[str] = None,
8686
):
8787
"""Define devices and where to serve them.
@@ -119,6 +119,9 @@ def construct_devices() -> Dict[str, Device]:
119119
]
120120
121121
"""
122+
if conf is None:
123+
conf = {}
124+
122125
if not callable(cls):
123126
raise TypeError("cls must be a callable")
124127
elif isinstance(cls, type):

0 commit comments

Comments
 (0)