Skip to content

Commit 5b44de8

Browse files
authored
fix black formatting from StyleCheck 625 (#160)
* fix black formatting from StyleCheck 625 * style guide documentation updates * more black updates * reference f-strings
1 parent a38e266 commit 5b44de8

File tree

8 files changed

+19
-23
lines changed

8 files changed

+19
-23
lines changed

STYLE_GUIDE.rst

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
STYLE GUIDE
22
==============
33

4-
As a rough style guide, please lint your code with pep8::
4+
As a rough style guide, please lint your code with black, codespell, and flake8::
55

6-
pip install pep8
7-
pep8 --ignore E501,E226,E241 sc2reader
6+
pip install black codespell flake8
7+
codespell -L queenland,uint
8+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
9+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
10+
black . --check
811

12+
More up-to-date checks may be detailed in `.circleci/config.yml`.
913

1014
All files should start with the following::
1115

@@ -17,11 +21,4 @@ All files should start with the following::
1721

1822
All imports should be absolute.
1923

20-
21-
All string formatting sound be done in the following style::
22-
23-
"my {0} formatted {1} string {2}".format("super", "python", "example")
24-
"the {x} style of {y} is also {z}".format(x="dict", y="arguments", z="acceptable")
25-
26-
The format argument index numbers are important for 2.6 support. ``%`` formatting is not allowed for 3.x support
27-
24+
All string formatting should be done with f-strings. See https://docs.python.org/3/reference/lexical_analysis.html#f-strings

docs/source/conf.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
master_doc = "index"
4444

4545
# General information about the project.
46-
project = u"sc2reader"
47-
copyright = u"2011-2013"
46+
project = "sc2reader"
47+
copyright = "2011-2013"
4848

4949
# The version info for the project you're documenting, acts as replacement for
5050
# |version| and |release|, also used in various other places throughout the
@@ -182,7 +182,7 @@
182182
# Grouping the document tree into LaTeX files. List of tuples
183183
# (source start file, target name, title, author, documentclass [howto/manual]).
184184
latex_documents = [
185-
("index", "sc2reader.tex", u"sc2reader Documentation", u"Graylin Kim", "manual")
185+
("index", "sc2reader.tex", "sc2reader Documentation", "Graylin Kim", "manual")
186186
]
187187

188188
# The name of an image file (relative to this directory) to place at the top of
@@ -213,4 +213,4 @@
213213

214214
# One entry per manual page. List of tuples
215215
# (source start file, name, description, authors, manual section).
216-
man_pages = [("index", "sc2reader", u"sc2reader Documentation", [u"Graylin Kim"], 1)]
216+
man_pages = [("index", "sc2reader", "sc2reader Documentation", ["Graylin Kim"], 1)]

sc2reader/engine/plugins/creeptracker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def radius_to_map_positions(self, radius):
173173
# Sample a square area using the radius
174174
for x in range(-radius, radius):
175175
for y in range(-radius, radius):
176-
if (x ** 2 + y ** 2) <= (radius * radius):
176+
if (x**2 + y**2) <= (radius * radius):
177177
output_coordinates.append((x, y))
178178
return output_coordinates
179179

sc2reader/events/tracker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class TrackerEvent(Event):
1717
def __init__(self, frames):
1818
#: The frame of the game this event was applied
1919
#: Ignore all but the lowest 32 bits of the frame
20-
self.frame = frames % 2 ** 32
20+
self.frame = frames % 2**32
2121

2222
#: The second of the game (game time not real time) this event was applied
2323
self.second = self.frame >> 4

sc2reader/readers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ def __call__(self, data, replay):
561561
)
562562

563563
# Don't want to do this more than once
564-
SINGLE_BIT_MASKS = [0x1 << i for i in range(2 ** 9)]
564+
SINGLE_BIT_MASKS = [0x1 << i for i in range(2**9)]
565565

566566
def read_selection_bitmask(self, data, mask_length):
567567
bits_left = mask_length

sc2reader/resources.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -421,11 +421,11 @@ def load_details(self):
421421
# the value required to get the adjusted timestamp. We know the upper
422422
# limit for any adjustment number so use that to distinguish between
423423
# the two cases.
424-
if details["utc_adjustment"] < 10 ** 7 * 60 * 60 * 24:
425-
self.time_zone = details["utc_adjustment"] / (10 ** 7 * 60 * 60)
424+
if details["utc_adjustment"] < 10**7 * 60 * 60 * 24:
425+
self.time_zone = details["utc_adjustment"] / (10**7 * 60 * 60)
426426
else:
427427
self.time_zone = (details["utc_adjustment"] - details["file_time"]) / (
428-
10 ** 7 * 60 * 60
428+
10**7 * 60 * 60
429429
)
430430

431431
self.game_length = self.length

sc2reader/scripts/sc2replayer.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ def getch():
2828
termios.tcsetattr(fd, termios.TCSAFLUSH, oldterm)
2929
fcntl.fcntl(fd, fcntl.F_SETFL, oldflags)
3030

31-
3231
except ImportError as e:
3332
try:
3433
# Oops, we might be on windows, try this one

sc2reader/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def windows_to_unix(windows_time):
4545
# This windows timestamp measures the number of 100 nanosecond periods since
4646
# January 1st, 1601. First we subtract the number of nanosecond periods from
4747
# 1601-1970, then we divide by 10^7 to bring it back to seconds.
48-
return int((windows_time - 116444735995904000) / 10 ** 7)
48+
return int((windows_time - 116444735995904000) / 10**7)
4949

5050

5151
@loggable

0 commit comments

Comments
 (0)