Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core API: Remove deprecated properties #1768

Merged
merged 5 commits into from
Jun 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 0 additions & 28 deletions docs/api/core.rst
Original file line number Diff line number Diff line change
Expand Up @@ -208,38 +208,12 @@ Deprecated API features
Though these features still work, they are slated to go away in the next
major Mopidy release.

Core
----

.. autoattribute:: mopidy.core.Core.version
.. autoattribute:: mopidy.core.Core.uri_schemes

TracklistController
-------------------

.. autoattribute:: mopidy.core.TracklistController.tl_tracks
.. autoattribute:: mopidy.core.TracklistController.tracks
.. autoattribute:: mopidy.core.TracklistController.version
.. autoattribute:: mopidy.core.TracklistController.length

.. autoattribute:: mopidy.core.TracklistController.consume
.. autoattribute:: mopidy.core.TracklistController.random
.. autoattribute:: mopidy.core.TracklistController.repeat
.. autoattribute:: mopidy.core.TracklistController.single

PlaybackController
------------------

.. automethod:: mopidy.core.PlaybackController.get_mute
.. automethod:: mopidy.core.PlaybackController.get_volume

.. autoattribute:: mopidy.core.PlaybackController.current_tl_track
.. autoattribute:: mopidy.core.PlaybackController.current_track
.. autoattribute:: mopidy.core.PlaybackController.state
.. autoattribute:: mopidy.core.PlaybackController.time_position
.. autoattribute:: mopidy.core.PlaybackController.mute
.. autoattribute:: mopidy.core.PlaybackController.volume

LibraryController
-----------------

Expand All @@ -250,5 +224,3 @@ PlaylistsController

.. automethod:: mopidy.core.PlaylistsController.filter
.. automethod:: mopidy.core.PlaylistsController.get_playlists

.. autoattribute:: mopidy.core.PlaylistsController.playlists
21 changes: 20 additions & 1 deletion docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,26 @@ Dependencies
Core API
--------

- (no changes yet)
- Removed properties that has been deprecated since 1.0, released in 2015.
Everything removed has corresponding methods that should be used instead.

- :attr:`mopidy.core.Core.uri_schemes`
- :attr:`mopidy.core.Core.version`
- :attr:`mopidy.core.PlaybackController.current_tl_track`
- :attr:`mopidy.core.PlaybackController.current_track`
- :attr:`mopidy.core.PlaybackController.state`
- :attr:`mopidy.core.PlaybackController.time_position`
- :attr:`mopidy.core.PlaybackController.volume`
- :attr:`mopidy.core.PlaybackController.mute`
- :attr:`mopidy.core.PlaylistController.playlists`
- :attr:`mopidy.core.TracklistController.tl_tracks`
- :attr:`mopidy.core.TracklistController.tracks`
- :attr:`mopidy.core.TracklistController.length`
- :attr:`mopidy.core.TracklistController.version`
- :attr:`mopidy.core.TracklistController.consume`
- :attr:`mopidy.core.TracklistController.random`
- :attr:`mopidy.core.TracklistController.repeat`
- :attr:`mopidy.core.TracklistController.single`

Backend API
-----------
Expand Down
13 changes: 0 additions & 13 deletions mopidy/core/actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from mopidy.core.playlists import PlaylistsController
from mopidy.core.tracklist import TracklistController
from mopidy.internal import path, storage, validation, versioning
from mopidy.internal.deprecation import deprecated_property
from mopidy.internal.models import CoreState


Expand Down Expand Up @@ -71,22 +70,10 @@ def get_uri_schemes(self):
uri_schemes = itertools.chain(*results)
return sorted(uri_schemes)

uri_schemes = deprecated_property(get_uri_schemes)
"""
.. deprecated:: 1.0
Use :meth:`get_uri_schemes` instead.
"""

def get_version(self):
"""Get version of the Mopidy core API"""
return versioning.get_version()

version = deprecated_property(get_version)
"""
.. deprecated:: 1.0
Use :meth:`get_version` instead.
"""

def reached_end_of_stream(self):
self.playback._on_end_of_stream()

Expand Down
57 changes: 6 additions & 51 deletions mopidy/core/playback.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ def _get_backend(self, tl_track):
uri_scheme = urllib.parse.urlparse(tl_track.track.uri).scheme
return self.backends.with_playback.get(uri_scheme, None)

# Properties

def get_current_tl_track(self):
"""Get the currently playing or selected track.

Expand All @@ -60,12 +58,6 @@ def _set_current_tl_track(self, value):
"""
self._current_tl_track = value

current_tl_track = deprecation.deprecated_property(get_current_tl_track)
"""
.. deprecated:: 1.0
Use :meth:`get_current_tl_track` instead.
"""

def get_current_track(self):
"""
Get the currently playing or selected track.
Expand All @@ -76,12 +68,6 @@ def get_current_track(self):
"""
return getattr(self.get_current_tl_track(), 'track', None)

current_track = deprecation.deprecated_property(get_current_track)
"""
.. deprecated:: 1.0
Use :meth:`get_current_track` instead.
"""

def get_current_tlid(self):
"""
Get the currently playing or selected TLID.
Expand Down Expand Up @@ -127,12 +113,6 @@ def set_state(self, new_state):

self._trigger_playback_state_changed(old_state, new_state)

state = deprecation.deprecated_property(get_state, set_state)
"""
.. deprecated:: 1.0
Use :meth:`get_state` and :meth:`set_state` instead.
"""

def get_time_position(self):
"""Get time position in milliseconds."""
if self._pending_position is not None:
Expand All @@ -144,12 +124,6 @@ def get_time_position(self):
else:
return 0

time_position = deprecation.deprecated_property(get_time_position)
"""
.. deprecated:: 1.0
Use :meth:`get_time_position` instead.
"""

def get_volume(self):
"""
.. deprecated:: 1.0
Expand All @@ -168,15 +142,6 @@ def set_volume(self, volume):
deprecation.warn('core.playback.set_volume')
return self.core.mixer.set_volume(volume)

volume = deprecation.deprecated_property(get_volume, set_volume)
"""
.. deprecated:: 1.0
Use :meth:`core.mixer.get_volume()
<mopidy.core.MixerController.get_volume>` and
:meth:`core.mixer.set_volume()
<mopidy.core.MixerController.set_volume>` instead.
"""

def get_mute(self):
"""
.. deprecated:: 1.0
Expand All @@ -195,17 +160,6 @@ def set_mute(self, mute):
deprecation.warn('core.playback.set_mute')
return self.core.mixer.set_mute(mute)

mute = deprecation.deprecated_property(get_mute, set_mute)
"""
.. deprecated:: 1.0
Use :meth:`core.mixer.get_mute()
<mopidy.core.MixerController.get_mute>` and
:meth:`core.mixer.set_mute()
<mopidy.core.MixerController.set_mute>` instead.
"""

# Methods

def _on_end_of_stream(self):
self.set_state(PlaybackState.STOPPED)
if self._current_tl_track:
Expand Down Expand Up @@ -301,10 +255,11 @@ def _on_tracklist_change(self):

Used by :class:`mopidy.core.TracklistController`.
"""
if not self.core.tracklist.tl_tracks:
tl_tracks = self.core.tracklist.get_tl_tracks()
if not tl_tracks:
self.stop()
self._set_current_tl_track(None)
elif self.get_current_tl_track() not in self.core.tracklist.tl_tracks:
elif self.get_current_tl_track() not in tl_tracks:
self._set_current_tl_track(None)

def next(self):
Expand Down Expand Up @@ -511,7 +466,7 @@ def seek(self, time_position):
'Client seeked to negative position. Seeking to zero.')
time_position = 0

if not self.core.tracklist.tracks:
if not self.core.tracklist.get_length():
return False

if self.get_state() == PlaybackState.STOPPED:
Expand Down Expand Up @@ -558,7 +513,7 @@ def stop(self):

def _trigger_track_playback_paused(self):
logger.debug('Triggering track playback paused event')
if self.current_track is None:
if self.get_current_tl_track() is None:
return
listener.CoreListener.send(
'track_playback_paused',
Expand All @@ -567,7 +522,7 @@ def _trigger_track_playback_paused(self):

def _trigger_track_playback_resumed(self):
logger.debug('Triggering track playback resumed event')
if self.current_track is None:
if self.get_current_tl_track() is None:
return
listener.CoreListener.send(
'track_playback_resumed',
Expand Down
8 changes: 1 addition & 7 deletions mopidy/core/playlists.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,6 @@ def get_playlists(self, include_tracks=True):
return [
Playlist(uri=r.uri, name=r.name) for r in playlist_refs]

playlists = deprecation.deprecated_property(get_playlists)
"""
.. deprecated:: 1.0
Use :meth:`as_list` and :meth:`get_items` instead.
"""

def create(self, name, uri_scheme=None):
"""
Create a new playlist.
Expand Down Expand Up @@ -238,7 +232,7 @@ def filter(self, criteria=None, **kwargs):
validation.check_query(
criteria, validation.PLAYLIST_FIELDS, list_values=False)

matches = self.playlists # TODO: stop using self playlists
matches = self.get_playlists()
for (key, value) in criteria.iteritems():
matches = filter(lambda p: getattr(p, key) == value, matches)
return matches
Expand Down
52 changes: 0 additions & 52 deletions mopidy/core/tracklist.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,38 +23,18 @@ def __init__(self, core):

self._shuffled = []

# Properties

def get_tl_tracks(self):
"""Get tracklist as list of :class:`mopidy.models.TlTrack`."""
return self._tl_tracks[:]

tl_tracks = deprecation.deprecated_property(get_tl_tracks)
"""
.. deprecated:: 1.0
Use :meth:`get_tl_tracks` instead.
"""

def get_tracks(self):
"""Get tracklist as list of :class:`mopidy.models.Track`."""
return [tl_track.track for tl_track in self._tl_tracks]

tracks = deprecation.deprecated_property(get_tracks)
"""
.. deprecated:: 1.0
Use :meth:`get_tracks` instead.
"""

def get_length(self):
"""Get length of the tracklist."""
return len(self._tl_tracks)

length = deprecation.deprecated_property(get_length)
"""
.. deprecated:: 1.0
Use :meth:`get_length` instead.
"""

def get_version(self):
"""
Get the tracklist version.
Expand All @@ -69,12 +49,6 @@ def _increase_version(self):
self.core.playback._on_tracklist_change()
self._trigger_tracklist_changed()

version = deprecation.deprecated_property(get_version)
"""
.. deprecated:: 1.0
Use :meth:`get_version` instead.
"""

def get_consume(self):
"""Get consume mode.

Expand All @@ -98,12 +72,6 @@ def set_consume(self, value):
self._trigger_options_changed()
return setattr(self, '_consume', value)

consume = deprecation.deprecated_property(get_consume, set_consume)
"""
.. deprecated:: 1.0
Use :meth:`get_consume` and :meth:`set_consume` instead.
"""

def get_random(self):
"""Get random mode.

Expand All @@ -130,12 +98,6 @@ def set_random(self, value):
random.shuffle(self._shuffled)
return setattr(self, '_random', value)

random = deprecation.deprecated_property(get_random, set_random)
"""
.. deprecated:: 1.0
Use :meth:`get_random` and :meth:`set_random` instead.
"""

def get_repeat(self):
"""
Get repeat mode.
Expand Down Expand Up @@ -163,12 +125,6 @@ def set_repeat(self, value):
self._trigger_options_changed()
return setattr(self, '_repeat', value)

repeat = deprecation.deprecated_property(get_repeat, set_repeat)
"""
.. deprecated:: 1.0
Use :meth:`get_repeat` and :meth:`set_repeat` instead.
"""

def get_single(self):
"""
Get single mode.
Expand All @@ -194,14 +150,6 @@ def set_single(self, value):
self._trigger_options_changed()
return setattr(self, '_single', value)

single = deprecation.deprecated_property(get_single, set_single)
"""
.. deprecated:: 1.0
Use :meth:`get_single` and :meth:`set_single` instead.
"""

# Methods

def index(self, tl_track=None, tlid=None):
"""
The position of the given track in the tracklist.
Expand Down
14 changes: 0 additions & 14 deletions mopidy/internal/deprecation.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,3 @@ def ignore(ids=None):
else:
warnings.filterwarnings('ignore', category=DeprecationWarning)
yield


def deprecated_property(
getter=None, setter=None, message='Property is deprecated'):

# During development, this is a convenient place to add logging, emit
# warnings, or ``assert False`` to ensure you are not using any of the
# deprecated properties.
#
# Using inspect to find the call sites to emit proper warnings makes
# parallel execution of our test suite slower than serial execution. Thus,
# we don't want to add any extra overhead here by default.

return property(getter, setter)
Loading