Skip to content
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ ignore-on-opaque-inference=yes
# List of class names for which member attributes should not be checked (useful
# for classes with dynamically set attributes). This supports the use of
# qualified names.
ignored-classes=optparse.Values,thread._local,_thread._local
ignored-classes=thread._local,_thread._local

# List of module names for which member attributes should not be checked
# (useful for modules/projects where namespaces are manipulated during runtime
Expand Down
19 changes: 1 addition & 18 deletions picard/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.


from picard.version import (
Version,
VersionError,
)
from picard.version import Version


PICARD_ORG_NAME = "MusicBrainz"
Expand All @@ -51,20 +48,6 @@
PICARD_BUILD_VERSION_STR = ""


def version_to_string(version, short=False):
"""Deprecated: Use picard.version.Version.to_string instead"""
if len(version) != 5:
raise VersionError("Length != 5")
if not isinstance(version, Version):
version = Version(*version)
return version.to_string(short=short)


def version_from_string(version_str):
"""Deprecated: Use picard.version.Version.from_string instead"""
return Version.from_string(version_str)


PICARD_VERSION_STR = PICARD_VERSION.to_string()
PICARD_VERSION_STR_SHORT = PICARD_VERSION.to_string(short=True)
if PICARD_BUILD_VERSION_STR:
Expand Down
1 change: 0 additions & 1 deletion picard/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,6 @@ def add_unique(self, name, value):
self.add(name, value)

def delete(self, name):
"""Deprecated: use del directly"""
del self[self.normalize_tag(name)]

def unset(self, name):
Expand Down
9 changes: 0 additions & 9 deletions picard/util/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.


import builtins
from collections import namedtuple
from collections.abc import Mapping
from itertools import chain
Expand Down Expand Up @@ -706,14 +705,6 @@ def __convert_to_string(obj):
return str(obj)


def convert_to_string(obj):
log.warning("string_() and convert_to_string() are deprecated, do not use")
return __convert_to_string(obj)


builtins.__dict__['string_'] = convert_to_string


def load_json(data):
"""Deserializes a string or bytes like json response and converts
it to a python object.
Expand Down
3 changes: 1 addition & 2 deletions picard/util/thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,13 @@ def future_callback(callback, future, log_traceback=True):
to_main(callback, result=result, error=error)


def run_task(func, next_func, priority=0, thread_pool=None, traceback=True):
def run_task(func, next_func, thread_pool=None, traceback=True):
"""Schedules func to be run on a separate thread

Args:
func: Function to run on a separate thread.
next_func: Callback function to run after the thread has been completed.
The callback will be run on the main thread.
priority: Deprecated, for backward compatibility only
thread_pool: Instance of concurrent.futures.Executor to run this task.
traceback: If set to true the stack trace will be logged to the error log
if an exception was raised.
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# E501: line too long (xx > 79 characters)
# W503: line break occurred before a binary operator
ignore = E127,E128,E129,E226,E241,E501,W503
builtins = _,N_,ngettext,gettext_attributes,pgettext_attributes,gettext_countries,string_
builtins = _,N_,ngettext,gettext_attributes,pgettext_attributes,gettext_countries
exclude = ui_*.py,picard/resources.py

[coverage:run]
Expand Down
36 changes: 11 additions & 25 deletions test/test_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
from picard import (
api_versions,
api_versions_tuple,
version_from_string,
version_to_string,
)
from picard.version import (
Version,
Expand All @@ -53,10 +51,8 @@ def test_version_conversion(self):
(Version(1, 1, 2, 'rc', 2), '1.1.2.rc2'),
)
for v, s in versions:
self.assertEqual(version_to_string(v), s)
self.assertEqual(str(v), s)
self.assertEqual(v, Version.from_string(s))
self.assertEqual(v, version_from_string(s))

def test_version_conversion_short(self):
versions = (
Expand All @@ -71,52 +67,42 @@ def test_version_conversion_short(self):
(Version(1, 1, 2, 'rc', 2), '1.1.2rc2'),
)
for v, s in versions:
self.assertEqual(version_to_string(v, short=True), s)
self.assertEqual(v.to_string(short=True), s)
self.assertEqual(v, Version.from_string(s))
self.assertEqual(v, version_from_string(s))

def test_version_to_string_invalid_identifier(self):
invalid = (1, 0, 2, 'xx', 0)
self.assertRaises(VersionError, version_to_string, (invalid))

def test_version_from_string_underscores(self):
l, s = (1, 1, 0, 'dev', 0), '1_1_0_dev_0'
self.assertEqual(l, version_from_string(s))
self.assertEqual(l, Version.from_string(s))

def test_version_from_string_prefixed(self):
l, s = (1, 1, 0, 'dev', 0), 'anything_28_1_1_0_dev_0'
self.assertEqual(l, version_from_string(s))
self.assertEqual(l, Version.from_string(s))

def test_version_single_digit(self):
l, s = (2, 0, 0, 'final', 0), '2'
self.assertEqual(l, version_from_string(s))
self.assertEqual(l, Version.from_string(s))
self.assertEqual(l, Version(2))

def test_version_from_string_invalid(self):
invalid = 'anything_28x_1_0_dev_0'
self.assertRaises(VersionError, version_to_string, (invalid))

def test_version_from_string_prefixed_final(self):
l, s = (1, 1, 0, 'final', 0), 'anything_28_1_1_0'
self.assertEqual(l, version_from_string(s))
self.assertEqual(l, Version.from_string(s))

def test_from_string_invalid_identifier(self):
self.assertRaises(VersionError, version_from_string, '1.1.0dev')
self.assertRaises(VersionError, version_from_string, '1.1.0devx')
self.assertRaises(VersionError, Version.from_string, '1.1.0dev')
self.assertRaises(VersionError, Version.from_string, '1.1.0devx')

def test_version_from_string_invalid_partial(self):
self.assertRaises(VersionError, version_from_string, '1dev')
self.assertRaises(VersionError, version_from_string, '1.0dev')
self.assertRaises(VersionError, version_from_string, '123.')
self.assertRaises(VersionError, Version.from_string, '1dev')
self.assertRaises(VersionError, Version.from_string, '1.0dev')
self.assertRaises(VersionError, Version.from_string, '123.')

@unittest.skipUnless(len(api_versions) > 1, "api_versions do not have enough elements")
def test_api_versions_1(self):
"""Check api versions format and order (from oldest to newest)"""

for i in range(len(api_versions) - 1):
a = version_from_string(api_versions[i])
b = version_from_string(api_versions[i+1])
a = Version.from_string(api_versions[i])
b = Version.from_string(api_versions[i+1])
self.assertLess(a, b)

@unittest.skipUnless(len(api_versions_tuple) > 1, "api_versions_tuple do not have enough elements")
Expand Down