@@ -24,6 +24,47 @@ _Notes on the upcoming release will be added here_
2424
2525<!-- Maintainers, insert migration notes for the next release here -->
2626
27+ ### URLs: Mapping now class attributes (#433 )
28+
29+ ` URL.rule_map ` is now a class attribute rather than a dataclass attribute.
30+
31+ Before:
32+
33+ ``` python
34+ @dataclasses.dataclass (repr = False )
35+ class GitLabURL (GitURL ):
36+ rule_map: RuleMap = RuleMap(
37+ _rule_map = {' gitlab_prefix' : GitLabPrefix}
38+ )
39+ ```
40+
41+ In python 3.11, that raises an error:
42+
43+ ``` console
44+ File "/home/user/.python/3.11.0/lib/python3.11/dataclasses.py", line 1211, in wrap
45+ return _process_class(cls, init, repr, eq, order, unsafe_hash,
46+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
47+ File "/home/user/.python/3.11.0/lib/python3.11/dataclasses.py", line 959, in _process_class
48+ cls_fields.append(_get_field(cls, name, type, kw_only))
49+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
50+ File "/home/user/.python/3.11.0/lib/python3.11/dataclasses.py", line 816, in _get_field
51+ raise ValueError(f'mutable default {type(f.default)} for field '
52+ ValueError: mutable default <class 'libvcs.url.base.RuleMap'> for field rule_map is not allowed: use default_factory
53+ ```
54+
55+ After release:
56+
57+ ``` python
58+ >> > import dataclasses
59+ >> > from libvcs.url.base import RuleMap
60+ >> > from libvcs.url.git import GitURL, DEFAULT_RULES
61+ >> > @ dataclasses.dataclass(repr = False )
62+ ... class MyGitURL (GitURL ):
63+ ... rule_map = RuleMap(
64+ ... _rule_map = {' gitlab_prefix' : DEFAULT_RULES }
65+ ... )
66+ ```
67+
2768<!-- -
2869# vim: set filetype=markdown:
2970-->
0 commit comments