Skip to content

Commit 8219cf3

Browse files
committed
fix: remove mutable defaults
1 parent 4615e33 commit 8219cf3

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

fortls/objects.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,17 @@ def get_use_tree(
4242
scope: Scope,
4343
use_dict: dict[str, Use | Import],
4444
obj_tree: dict,
45-
only_list: set[str] = set(),
46-
rename_map: dict[str, str] = {},
47-
curr_path: list[str] = [],
45+
only_list: list[str] = None,
46+
rename_map: dict[str, str] = None,
47+
curr_path: list[str] = None,
4848
):
49+
if only_list is None:
50+
only_list = set()
51+
if rename_map is None:
52+
rename_map = {}
53+
if curr_path is None:
54+
curr_path = []
55+
4956
def intersect_only(use_stmnt: Use | Import):
5057
tmp_list = []
5158
tmp_map = rename_map.copy()
@@ -318,10 +325,12 @@ class Use:
318325
def __init__(
319326
self,
320327
mod_name: str,
321-
only_list: set[str] = set(),
328+
only_list: set[str] = None,
322329
rename_map: dict[str, str] = None,
323-
line_number: int | None = 0,
330+
line_number: int = 0,
324331
):
332+
if only_list is None:
333+
only_list = set()
325334
if rename_map is None:
326335
rename_map = {}
327336
self.mod_name: str = mod_name.lower()
@@ -364,10 +373,12 @@ def __init__(
364373
self,
365374
name: str,
366375
import_type: ImportTypes = ImportTypes.DEFAULT,
367-
only_list: set[str] = set(),
376+
only_list: set[str] = None,
368377
rename_map: dict[str, str] = None,
369378
line_number: int = 0,
370379
):
380+
if only_list is None:
381+
only_list = set()
371382
if rename_map is None:
372383
rename_map = {}
373384
super().__init__(name, only_list, rename_map, line_number)

0 commit comments

Comments
 (0)