Skip to content

Commit fdcfae2

Browse files
committed
Upgrade Python syntax with pyupgrade --py3-plus
1 parent 466a260 commit fdcfae2

File tree

6 files changed

+17
-25
lines changed

6 files changed

+17
-25
lines changed

docs/conf.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
#
32
# Python LiveReload documentation build configuration file, created by
43
# sphinx-quickstart on Sat May 5 18:36:44 2012.
@@ -42,8 +41,8 @@
4241
master_doc = 'index'
4342

4443
# General information about the project.
45-
project = u'Python LiveReload'
46-
copyright = u'2012, <a href="http://lepture.com">Hsiaoming Yang</a>'
44+
project = 'Python LiveReload'
45+
copyright = '2012, <a href="http://lepture.com">Hsiaoming Yang</a>'
4746

4847
# The version info for the project you're documenting, acts as replacement for
4948
# |version| and |release|, also used in various other places throughout the
@@ -192,8 +191,8 @@
192191
# Grouping the document tree into LaTeX files. List of tuples
193192
# (source start file, target name, title, author, documentclass [howto/manual]).
194193
latex_documents = [
195-
('index', 'PythonLiveReload.tex', u'Python LiveReload Documentation',
196-
u'Hsiaoming Yang', 'manual'),
194+
('index', 'PythonLiveReload.tex', 'Python LiveReload Documentation',
195+
'Hsiaoming Yang', 'manual'),
197196
]
198197

199198
# The name of an image file (relative to this directory) to place at the top of
@@ -222,8 +221,8 @@
222221
# One entry per manual page. List of tuples
223222
# (source start file, name, description, authors, manual section).
224223
man_pages = [
225-
('index', 'livereload', u'Python LiveReload Documentation',
226-
[u'Hsiaoming Yang'], 1)
224+
('index', 'livereload', 'Python LiveReload Documentation',
225+
['Hsiaoming Yang'], 1)
227226
]
228227

229228
# If true, show URL addresses after external links.
@@ -236,8 +235,8 @@
236235
# (source start file, target name, title, author,
237236
# dir menu entry, description, category)
238237
texinfo_documents = [
239-
('index', 'PythonLiveReload', u'Python LiveReload Documentation',
240-
u'Hsiaoming Yang', 'PythonLiveReload', 'One line description of project.',
238+
('index', 'PythonLiveReload', 'Python LiveReload Documentation',
239+
'Hsiaoming Yang', 'PythonLiveReload', 'One line description of project.',
241240
'Miscellaneous'),
242241
]
243242

livereload/handlers.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
"""
32
livereload.handlers
43
~~~~~~~~~~~~~~~~~~~

livereload/server.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
"""
32
livereload.server
43
~~~~~~~~~~~~~~~~~
@@ -94,8 +93,7 @@ def run_shell():
9493
logger.error(stderr)
9594
return stderr
9695
#: stdout is bytes, decode for python3
97-
if PY3:
98-
stdout = stdout.decode()
96+
stdout = stdout.decode()
9997
with open(output, mode) as f:
10098
f.write(stdout)
10199

@@ -104,7 +102,7 @@ def run_shell():
104102

105103
class LiveScriptInjector(web.OutputTransform):
106104
def __init__(self, request):
107-
super(LiveScriptInjector, self).__init__(request)
105+
super().__init__(request)
108106

109107
def transform_first_chunk(self, status_code, headers, chunk, finishing):
110108
if HEAD_END in chunk:
@@ -143,7 +141,7 @@ def start_response(status, response_headers, exc_info=None):
143141
status_code, reason = data["status"].split(' ', 1)
144142
status_code = int(status_code)
145143
headers = data["headers"]
146-
header_set = set(k.lower() for (k, v) in headers)
144+
header_set = {k.lower() for (k, v) in headers}
147145
body = escape.utf8(body)
148146

149147
if HEAD_END in body:
@@ -174,7 +172,7 @@ def start_response(status, response_headers, exc_info=None):
174172
self._log(status_code, request)
175173

176174

177-
class Server(object):
175+
class Server:
178176
"""Livereload server interface.
179177
180178
Initialize a server and watch file changes::
@@ -239,7 +237,7 @@ def alert():
239237
:param ignore: A function return True to ignore a certain pattern of
240238
filepath.
241239
"""
242-
if isinstance(func, string_types):
240+
if isinstance(func, str):
243241
cmd = func
244242
func = shell(func)
245243
func.name = "shell: {}".format(cmd)
@@ -332,7 +330,7 @@ def serve(self, port=5500, liveport=None, host=None, root=None, debug=None,
332330
self.root = root
333331

334332
self._setup_logging()
335-
logger.info('Serving on http://%s:%s' % (host, port))
333+
logger.info('Serving on http://{}:{}'.format(host, port))
336334

337335
self.default_filename = default_filename
338336

@@ -346,7 +344,7 @@ def serve(self, port=5500, liveport=None, host=None, root=None, debug=None,
346344

347345
def opener():
348346
time.sleep(open_url_delay)
349-
webbrowser.open('http://%s:%s' % (host, port))
347+
webbrowser.open('http://{}:{}'.format(host, port))
350348
threading.Thread(target=opener).start()
351349

352350
try:

livereload/watcher.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
"""
32
livereload.watcher
43
~~~~~~~~~~~~~~~~~~
@@ -28,7 +27,7 @@
2827
logger = logging.getLogger('livereload')
2928

3029

31-
class Watcher(object):
30+
class Watcher:
3231
"""A file watcher registry."""
3332
def __init__(self):
3433
self._tasks = {}

server.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# coding: utf-8
2-
31
from livereload import Server, shell
42

53
server = Server()

setup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
#!/usr/bin/env python
2-
# -*- coding: utf-8 -*-
32

43
import re
54
from setuptools import setup
65

76

87
def fread(filepath):
9-
with open(filepath, 'r') as f:
8+
with open(filepath) as f:
109
return f.read()
1110

1211

0 commit comments

Comments
 (0)