@@ -45,7 +45,7 @@ class Enclosure(common.StrEnum):
4545 NONAGON = 'nonagon'
4646 DECAGON = 'decagon'
4747 INVERTED_BRACKET = 'inverted-bracket'
48- NONE = 'none' # special -- sets to None.
48+ NO_ENCLOSURE = 'none'
4949
5050
5151class Style (ProtoM21Object ):
@@ -87,6 +87,8 @@ def __init__(self) -> None:
8787 # managed by property below.
8888 self ._absoluteY : float | int | None = None
8989
90+ # None means enclosure is left unspecified, NO_ENCLOSURE means
91+ # explicitly that there is no enclosure.
9092 self ._enclosure : Enclosure | None = None
9193
9294 # how should this symbol be represented in the font?
@@ -105,7 +107,8 @@ def __init__(self) -> None:
105107 @property
106108 def enclosure (self ) -> Enclosure | None :
107109 '''
108- Get or set the enclosure as a style.Enclosure enum or None.
110+ Get or set the enclosure as a style.Enclosure enum (or
111+ None, which means the enclosure is left unspecified).
109112
110113 Valid names are:
111114
@@ -115,7 +118,8 @@ def enclosure(self) -> Enclosure|None:
115118 * "circle"/style.Enclosure.CIRCLE,
116119 * "bracket"/style.Enclosure.BRACKET,
117120 * "inverted-bracket"/style.Enclosure.INVERTED_BRACKET (output in musicxml 4 only)
118- * None/"none"/style.Enclosure.NONE (returns Python None object)
121+ * "none"/style.Enclosure.NO_ENCLOSURE
122+ * None (i.e. enclosure is unspecified)
119123
120124 or the following other shapes with their ALLCAPS Enclosure equivalents:
121125
@@ -151,15 +155,16 @@ def enclosure(self) -> Enclosure|None:
151155 Traceback (most recent call last):
152156 music21.style.TextFormatException:
153157 Not a supported enclosure: 4
158+
159+ * Changed in v9.7: We now differentiate between no enclosure
160+ (Enclosure.NO_ENCLOSURE) and unspecified enclosure (None).
154161 '''
155162 return self ._enclosure
156163
157164 @enclosure .setter
158- def enclosure (self , value : Enclosure | None ):
165+ def enclosure (self , value : Enclosure | str | None ):
159166 if value is None :
160167 self ._enclosure = value
161- elif value == Enclosure .NONE :
162- self ._enclosure = None
163168 elif isinstance (value , Enclosure ):
164169 self ._enclosure = value
165170 elif isinstance (value , str ):
0 commit comments