Skip to content

Commit a47c24d

Browse files
committed
Update to pass flake8 hook
Make the changes necessary to pass the flake8 hook we have in our pre-commit configuration. Some tweaks were made to docstrings as part of this process. Note: The E203 check was disabled in the flake8 configuration.
1 parent 2bdf9bf commit a47c24d

File tree

11 files changed

+199
-105
lines changed

11 files changed

+199
-105
lines changed

.flake8

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ max-line-length = 80
1414
# * The B950 flake8-bugbear opinionated warning -
1515
# https://github.com/PyCQA/flake8-bugbear#opinionated-warnings
1616
select = C,D,E,F,W,B,B950
17+
# Ignore flake8's default warning about "whitespace before ':'" as it is not
18+
# PEP 8 compliant and conflicts with black's styling.
19+
#
1720
# Ignore flake8's default warning about maximum line length, which has
1821
# a hard stop at the configured value. Instead we use
1922
# flake8-bugbear's B950, which allows up to 10% overage.
@@ -22,4 +25,4 @@ select = C,D,E,F,W,B,B950
2225
# operators. It no longer agrees with PEP8. See, for example, here:
2326
# https://github.com/ambv/black/issues/21. Guido agrees here:
2427
# https://github.com/python/peps/commit/c59c4376ad233a62ca4b3a6060c81368bd21e85b.
25-
ignore = E501,W503
28+
ignore = E203,E501,W503

gce-scripts/combine_shards.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66

77
def main():
8+
"""Read a file with a list of shard filenames and combine them."""
89
if (len(sys.argv)) < 2:
910
print("you need a filename!")
1011
exit(1)

src/pshtt/cli.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939

4040

4141
def to_csv(results, out_filename):
42+
"""Output the provided results in CSV format to the provided filename."""
4243
utils.debug("Opening CSV file: {}".format(out_filename))
4344
with smart_open(out_filename) as out_file:
4445
writer = csv.writer(out_file)
@@ -55,6 +56,7 @@ def to_csv(results, out_filename):
5556

5657

5758
def to_json(results, out_filename):
59+
"""Output the provided results in JSON format to the provided filename."""
5860
# Generate (yield) all the results before exporting to JSON
5961
results = list(results)
6062

@@ -68,6 +70,7 @@ def to_json(results, out_filename):
6870

6971

7072
def to_markdown(results, out_filename):
73+
"""Output the provided results in Markdown format to the provided filename."""
7174
# Generate (yield) all the results before exporting to Markdown
7275
table = [[" %s" % result[header] for header in pshtt.HEADERS] for result in results]
7376

@@ -83,6 +86,7 @@ def to_markdown(results, out_filename):
8386

8487

8588
def main():
89+
"""Provide a command line interface to the pshtt library."""
8690
args = docopt.docopt(__doc__, version=__version__)
8791
utils.configure_logging(args["--debug"])
8892

src/pshtt/models.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1+
"""Define the models used in this library."""
2+
3+
14
class Domain(object):
5+
"""Define the domain model."""
6+
27
def __init__(self, domain):
8+
"""Initialize the model."""
39
self.domain = domain
410

511
# 4 endpoints for each domain.
@@ -13,6 +19,7 @@ def __init__(self, domain):
1319
self.canonical = None
1420

1521
def to_object(self):
22+
"""Convert the model to a dictionary."""
1623
return {
1724
"https": self.https.to_object(),
1825
"httpswww": self.httpswww.to_object(),
@@ -22,7 +29,10 @@ def to_object(self):
2229

2330

2431
class Endpoint(object):
32+
"""Define the endpoint model."""
33+
2534
def __init__(self, protocol, host, base_domain):
35+
"""Initialize the model."""
2636
# Basic endpoint description
2737
self.protocol = protocol
2838
self.host = host # "www" or "root"
@@ -77,6 +87,7 @@ def __init__(self, protocol, host, base_domain):
7787
self.hsts_preloaded = None
7888

7989
def url_for(self, protocol, host, base_domain):
90+
"""Return an appropriately formatted URL for the base domain."""
8091
if host == "root":
8192
prefix = ""
8293
elif host == "www":
@@ -86,6 +97,7 @@ def url_for(self, protocol, host, base_domain):
8697

8798
# The fields we want to serialize to JSON.
8899
def to_object(self):
100+
"""Convert the model to a dictionary."""
89101
obj = {
90102
"url": self.url,
91103
"headers": dict(self.headers),

0 commit comments

Comments
 (0)