Skip to content
This repository was archived by the owner on Jun 15, 2022. It is now read-only.

Commit ed3e24c

Browse files
committed
Use Black's default string normalization
1 parent b759f48 commit ed3e24c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1875
-1876
lines changed

docs/conf.py

+35-35
Original file line numberDiff line numberDiff line change
@@ -21,106 +21,106 @@ def get_version():
2121
# Get current library version without requiring the library to be
2222
# installed, like ``pkg_resources.get_distribution(...).version`` requires.
2323
cp = configparser.ConfigParser()
24-
cp.read(os.path.join(os.path.dirname(__file__), '..', 'setup.cfg'))
25-
return cp['metadata']['version']
24+
cp.read(os.path.join(os.path.dirname(__file__), "..", "setup.cfg"))
25+
return cp["metadata"]["version"]
2626

2727

2828
# -- Workarounds to have autodoc generate API docs ----------------------------
2929

30-
sys.path.insert(0, os.path.abspath('..'))
30+
sys.path.insert(0, os.path.abspath(".."))
3131

3232

3333
# Mock cffi module
3434
module = mock.Mock()
3535
module.ffi = mock.Mock()
3636
module.ffi.CData = bytes
3737
module.lib = mock.Mock()
38-
module.lib.sp_error_message.return_value = b''
39-
module.lib.sp_error_message.__name__ = str('sp_error_message')
40-
sys.modules['spotify._spotify'] = module
38+
module.lib.sp_error_message.return_value = b""
39+
module.lib.sp_error_message.__name__ = str("sp_error_message")
40+
sys.modules["spotify._spotify"] = module
4141

4242

4343
# Mock pkg_resources module
4444
module = mock.Mock()
4545
module.get_distribution.return_value.version = get_version()
46-
sys.modules['pkg_resources'] = module
46+
sys.modules["pkg_resources"] = module
4747

4848

4949
# Add all libspotify constants to the lib mock
50-
with open('sp-constants.csv') as fh:
50+
with open("sp-constants.csv") as fh:
5151
for line in fh.readlines():
52-
key, value = line.split(',', 1)
52+
key, value = line.split(",", 1)
5353
setattr(module.lib, key, value)
5454

5555

5656
# Unwrap decorated methods so Sphinx can inspect their signatures
5757
import spotify # noqa
5858

5959
for mod_name, mod in vars(spotify).items():
60-
if not isinstance(mod, types.ModuleType) or mod_name in ('threading',):
60+
if not isinstance(mod, types.ModuleType) or mod_name in ("threading",):
6161
continue
6262
for cls in vars(mod).values():
6363
if not isinstance(cls, type):
6464
continue
6565
for method_name, method in vars(cls).items():
66-
if hasattr(method, '__wrapped__'):
66+
if hasattr(method, "__wrapped__"):
6767
setattr(cls, method_name, method.__wrapped__)
6868

6969

7070
# -- General configuration ----------------------------------------------------
7171

72-
needs_sphinx = '1.0'
72+
needs_sphinx = "1.0"
7373

7474
extensions = [
75-
'sphinx.ext.autodoc',
76-
'sphinx.ext.extlinks',
77-
'sphinx.ext.intersphinx',
78-
'sphinx.ext.viewcode',
75+
"sphinx.ext.autodoc",
76+
"sphinx.ext.extlinks",
77+
"sphinx.ext.intersphinx",
78+
"sphinx.ext.viewcode",
7979
]
8080

81-
templates_path = ['_templates']
82-
source_suffix = '.rst'
83-
master_doc = 'index'
81+
templates_path = ["_templates"]
82+
source_suffix = ".rst"
83+
master_doc = "index"
8484

85-
project = 'pyspotify'
86-
copyright = '2013-2019, Stein Magnus Jodal and contributors'
85+
project = "pyspotify"
86+
copyright = "2013-2019, Stein Magnus Jodal and contributors"
8787

8888
release = get_version()
89-
version = '.'.join(release.split('.')[:2])
89+
version = ".".join(release.split(".")[:2])
9090

91-
exclude_patterns = ['_build']
91+
exclude_patterns = ["_build"]
9292

93-
pygments_style = 'sphinx'
93+
pygments_style = "sphinx"
9494

95-
modindex_common_prefix = ['spotify.']
95+
modindex_common_prefix = ["spotify."]
9696

97-
autodoc_default_flags = ['members', 'undoc-members', 'inherited-members']
98-
autodoc_member_order = 'bysource'
97+
autodoc_default_flags = ["members", "undoc-members", "inherited-members"]
98+
autodoc_member_order = "bysource"
9999

100100
intersphinx_mapping = {
101-
'python': ('http://docs.python.org/3/', None),
102-
'pyalsaaudio': ('https://larsimmisch.github.io/pyalsaaudio/', None),
101+
"python": ("http://docs.python.org/3/", None),
102+
"pyalsaaudio": ("https://larsimmisch.github.io/pyalsaaudio/", None),
103103
}
104104

105105

106106
# -- Options for HTML output --------------------------------------------------
107107

108108
# html_theme = 'default'
109-
html_static_path = ['_static']
109+
html_static_path = ["_static"]
110110

111111
html_use_modindex = True
112112
html_use_index = True
113113
html_split_index = False
114114
html_show_sourcelink = True
115115

116-
htmlhelp_basename = 'pyspotify'
116+
htmlhelp_basename = "pyspotify"
117117

118118
# -- Options for extlink extension --------------------------------------------
119119

120120
extlinks = {
121-
'issue': ('https://github.com/jodal/pyspotify/issues/%s', '#'),
122-
'ms-issue': (
123-
'https://github.com/mopidy/mopidy-spotify/issues/%s',
124-
'mopidy-spotify#',
121+
"issue": ("https://github.com/jodal/pyspotify/issues/%s", "#"),
122+
"ms-issue": (
123+
"https://github.com/mopidy/mopidy-spotify/issues/%s",
124+
"mopidy-spotify#",
125125
),
126126
}

examples/cover.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
while session.connection.state != spotify.ConnectionState.LOGGED_IN:
1010
session.process_events()
1111

12-
album = session.get_album('spotify:album:4m2880jivSbbyEGAKfITCa').load()
12+
album = session.get_album("spotify:album:4m2880jivSbbyEGAKfITCa").load()
1313
cover = album.cover(spotify.ImageSize.LARGE).load()
1414

15-
open('/tmp/cover.jpg', 'wb').write(cover.data)
16-
open('/tmp/cover.html', 'w').write('<img src="%s">' % cover.data_uri)
15+
open("/tmp/cover.jpg", "wb").write(cover.data)
16+
open("/tmp/cover.html", "w").write('<img src="%s">' % cover.data_uri)

examples/play_track.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
if sys.argv[1:]:
2727
track_uri = sys.argv[1]
2828
else:
29-
track_uri = 'spotify:track:6xZtSE6xaBxmRozKA0F6TA'
29+
track_uri = "spotify:track:6xZtSE6xaBxmRozKA0F6TA"
3030

3131
# Assuming a spotify_appkey.key in the current dir
3232
session = spotify.Session()

examples/shell.py

+26-26
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222

2323
class Commander(cmd.Cmd):
2424

25-
doc_header = 'Commands'
26-
prompt = 'spotify> '
25+
doc_header = "Commands"
26+
prompt = "spotify> "
2727

28-
logger = logging.getLogger('shell.commander')
28+
logger = logging.getLogger("shell.commander")
2929

3030
def __init__(self):
3131
cmd.Cmd.__init__(self)
@@ -44,7 +44,7 @@ def __init__(self):
4444
try:
4545
self.audio_driver = spotify.AlsaSink(self.session)
4646
except ImportError:
47-
self.logger.warning('No audio sink found; audio playback unavailable.')
47+
self.logger.warning("No audio sink found; audio playback unavailable.")
4848

4949
self.event_loop = spotify.EventLoop(self.session)
5050
self.event_loop.start()
@@ -62,43 +62,43 @@ def on_end_of_track(self, session):
6262

6363
def precmd(self, line):
6464
if line:
65-
self.logger.debug('New command: %s', line)
65+
self.logger.debug("New command: %s", line)
6666
return line
6767

6868
def emptyline(self):
6969
pass
7070

7171
def do_debug(self, line):
7272
"Show more logging output"
73-
print('Logging at DEBUG level')
73+
print("Logging at DEBUG level")
7474
logger = logging.getLogger()
7575
logger.setLevel(logging.DEBUG)
7676

7777
def do_info(self, line):
7878
"Show normal logging output"
79-
print('Logging at INFO level')
79+
print("Logging at INFO level")
8080
logger = logging.getLogger()
8181
logger.setLevel(logging.INFO)
8282

8383
def do_warning(self, line):
8484
"Show less logging output"
85-
print('Logging at WARNING level')
85+
print("Logging at WARNING level")
8686
logger = logging.getLogger()
8787
logger.setLevel(logging.WARNING)
8888

8989
def do_EOF(self, line):
9090
"Exit"
9191
if self.logged_in.is_set():
92-
print('Logging out...')
92+
print("Logging out...")
9393
self.session.logout()
9494
self.logged_out.wait()
9595
self.event_loop.stop()
96-
print('')
96+
print("")
9797
return True
9898

9999
def do_login(self, line):
100100
"login <username> <password>"
101-
tokens = line.split(' ', 1)
101+
tokens = line.split(" ", 1)
102102
if len(tokens) != 2:
103103
self.logger.warning("Wrong number of arguments")
104104
return
@@ -127,60 +127,60 @@ def do_whoami(self, line):
127127
"whoami"
128128
if self.logged_in.is_set():
129129
self.logger.info(
130-
'I am %s aka %s. You can find me at %s',
130+
"I am %s aka %s. You can find me at %s",
131131
self.session.user.canonical_name,
132132
self.session.user.display_name,
133133
self.session.user.link,
134134
)
135135
else:
136136
self.logger.info(
137-
'I am not logged in, but I may be %s',
137+
"I am not logged in, but I may be %s",
138138
self.session.remembered_user,
139139
)
140140

141141
def do_play_uri(self, line):
142142
"play <spotify track uri>"
143143
if not self.logged_in.is_set():
144-
self.logger.warning('You must be logged in to play')
144+
self.logger.warning("You must be logged in to play")
145145
return
146146
try:
147147
track = self.session.get_track(line)
148148
track.load()
149149
except (ValueError, spotify.Error) as e:
150150
self.logger.warning(e)
151151
return
152-
self.logger.info('Loading track into player')
152+
self.logger.info("Loading track into player")
153153
self.session.player.load(track)
154-
self.logger.info('Playing track')
154+
self.logger.info("Playing track")
155155
self.session.player.play()
156156

157157
def do_pause(self, line):
158-
self.logger.info('Pausing track')
158+
self.logger.info("Pausing track")
159159
self.session.player.play(False)
160160

161161
def do_resume(self, line):
162-
self.logger.info('Resuming track')
162+
self.logger.info("Resuming track")
163163
self.session.player.play()
164164

165165
def do_stop(self, line):
166-
self.logger.info('Stopping track')
166+
self.logger.info("Stopping track")
167167
self.session.player.play(False)
168168
self.session.player.unload()
169169

170170
def do_seek(self, seconds):
171171
"seek <seconds>"
172172
if not self.logged_in.is_set():
173-
self.logger.warning('You must be logged in to seek')
173+
self.logger.warning("You must be logged in to seek")
174174
return
175175
if self.session.player.state is spotify.PlayerState.UNLOADED:
176-
self.logger.warning('A track must be loaded before seeking')
176+
self.logger.warning("A track must be loaded before seeking")
177177
return
178178
self.session.player.seek(int(seconds) * 1000)
179179

180180
def do_search(self, query):
181181
"search <query>"
182182
if not self.logged_in.is_set():
183-
self.logger.warning('You must be logged in to search')
183+
self.logger.warning("You must be logged in to search")
184184
return
185185
try:
186186
result = self.session.search(query)
@@ -189,19 +189,19 @@ def do_search(self, query):
189189
self.logger.warning(e)
190190
return
191191
self.logger.info(
192-
'%d tracks, %d albums, %d artists, and %d playlists found.',
192+
"%d tracks, %d albums, %d artists, and %d playlists found.",
193193
result.track_total,
194194
result.album_total,
195195
result.artist_total,
196196
result.playlist_total,
197197
)
198-
self.logger.info('Top tracks:')
198+
self.logger.info("Top tracks:")
199199
for track in result.tracks:
200200
self.logger.info(
201-
'[%s] %s - %s', track.link, track.artists[0].name, track.name
201+
"[%s] %s - %s", track.link, track.artists[0].name, track.name
202202
)
203203

204204

205-
if __name__ == '__main__':
205+
if __name__ == "__main__":
206206
logging.basicConfig(level=logging.INFO)
207207
Commander().cmdloop()

pyproject.toml

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ requires = ["setuptools >= 30.3.0", "wheel"]
44

55
[tool.black]
66
target-version = ["py27"]
7-
skip-string-normalization = true
87

98

109
[tool.isort]

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33
setup(
44
# XXX Setting cffi_modules in setup.cfg does not have any effect.
5-
cffi_modules=['spotify/_spotify_build.py:ffi']
5+
cffi_modules=["spotify/_spotify_build.py:ffi"]
66
)

spotify/__init__.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import pkg_resources
66

7-
__version__ = pkg_resources.get_distribution('pyspotify').version
7+
__version__ = pkg_resources.get_distribution("pyspotify").version
88

99

1010
# Global reentrant lock to be held whenever libspotify functions are called or
@@ -28,7 +28,7 @@ def _setup_logging():
2828
"""
2929
import logging
3030

31-
logger = logging.getLogger('spotify')
31+
logger = logging.getLogger("spotify")
3232
handler = logging.NullHandler()
3333
logger.addHandler(handler)
3434

@@ -65,7 +65,7 @@ def wrapper(*args, **kwargs):
6565
with _lock:
6666
return f(*args, **kwargs)
6767

68-
if not hasattr(wrapper, '__wrapped__'):
68+
if not hasattr(wrapper, "__wrapped__"):
6969
# Workaround for Python < 3.2
7070
wrapper.__wrapped__ = f
7171
return wrapper
@@ -80,7 +80,7 @@ class _SerializedLib(object):
8080
def __init__(self, lib):
8181
for name in dir(lib):
8282
attr = getattr(lib, name)
83-
if name.startswith('sp_') and callable(attr):
83+
if name.startswith("sp_") and callable(attr):
8484
attr = serialized(attr)
8585
setattr(self, name, attr)
8686

0 commit comments

Comments
 (0)