diff --git a/music21/roman.py b/music21/roman.py index 2ef2e4cf5a..7d3a5b6cd2 100644 --- a/music21/roman.py +++ b/music21/roman.py @@ -42,6 +42,8 @@ # TODO: setting inversion should change the figure +T = t.TypeVar('T', bound='RomanNumeral') + # ----------------------------------------------------------------------------- @@ -3089,6 +3091,28 @@ def _updatePitches(self): f'_updatePitches() was unable to derive pitches from the figure: {self.figure!r}' ) # pragma: no cover + def transpose(self, value, *, inPlace=False) -> t.Optional[T]: + ''' + Overrides :meth:`~music21.harmony.Harmony.transpose` so that `key` + attribute is transposed as well. + + >>> rn = roman.RomanNumeral('I', 'C') + >>> rn + + >>> rn.transpose(4) + + >>> rn.transpose(-4, inPlace=True) + >>> rn + + ''' + post = super().transpose(value, inPlace=inPlace) + if not inPlace: + post.key = self.key.transpose(value, inPlace=False) + return post + else: + self.key.transpose(value, inPlace=True) + return None + # PUBLIC PROPERTIES #