Skip to content

Commit 3d3eda8

Browse files
committed
chore: Ran nox -s blacken
1 parent a3e65a5 commit 3d3eda8

File tree

1,190 files changed

+30600
-27958
lines changed

Some content is hidden

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

1,190 files changed

+30600
-27958
lines changed

appengine/flexible/analytics/main.py

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,52 +24,54 @@
2424

2525

2626
# Environment variables are defined in app.yaml.
27-
GA_TRACKING_ID = os.environ['GA_TRACKING_ID']
27+
GA_TRACKING_ID = os.environ["GA_TRACKING_ID"]
2828

2929

3030
def track_event(category, action, label=None, value=0):
3131
data = {
32-
'v': '1', # API Version.
33-
'tid': GA_TRACKING_ID, # Tracking ID / Property ID.
32+
"v": "1", # API Version.
33+
"tid": GA_TRACKING_ID, # Tracking ID / Property ID.
3434
# Anonymous Client Identifier. Ideally, this should be a UUID that
3535
# is associated with particular user, device, or browser instance.
36-
'cid': '555',
37-
't': 'event', # Event hit type.
38-
'ec': category, # Event category.
39-
'ea': action, # Event action.
40-
'el': label, # Event label.
41-
'ev': value, # Event value, must be an integer
42-
'ua': 'Opera/9.80 (Windows NT 6.0) Presto/2.12.388 Version/12.14'
36+
"cid": "555",
37+
"t": "event", # Event hit type.
38+
"ec": category, # Event category.
39+
"ea": action, # Event action.
40+
"el": label, # Event label.
41+
"ev": value, # Event value, must be an integer
42+
"ua": "Opera/9.80 (Windows NT 6.0) Presto/2.12.388 Version/12.14",
4343
}
4444

45-
response = requests.post(
46-
'https://www.google-analytics.com/collect', data=data)
45+
response = requests.post("https://www.google-analytics.com/collect", data=data)
4746

4847
# If the request fails, this will raise a RequestException. Depending
4948
# on your application's needs, this may be a non-error and can be caught
5049
# by the caller.
5150
response.raise_for_status()
5251

5352

54-
@app.route('/')
53+
@app.route("/")
5554
def track_example():
56-
track_event(
57-
category='Example',
58-
action='test action')
59-
return 'Event tracked.'
55+
track_event(category="Example", action="test action")
56+
return "Event tracked."
6057

6158

6259
@app.errorhandler(500)
6360
def server_error(e):
64-
logging.exception('An error occurred during a request.')
65-
return """
61+
logging.exception("An error occurred during a request.")
62+
return (
63+
"""
6664
An internal error occurred: <pre>{}</pre>
6765
See logs for full stacktrace.
68-
""".format(e), 500
66+
""".format(
67+
e
68+
),
69+
500,
70+
)
6971

7072

71-
if __name__ == '__main__':
73+
if __name__ == "__main__":
7274
# This is used when running locally. Gunicorn is used to run the
7375
# application on Google App Engine. See entrypoint in app.yaml.
74-
app.run(host='127.0.0.1', port=8080, debug=True)
76+
app.run(host="127.0.0.1", port=8080, debug=True)
7577
# [END gae_flex_analytics_track_event]

appengine/flexible/analytics/main_test.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
@pytest.fixture
2222
def app(monkeypatch):
23-
monkeypatch.setenv('GA_TRACKING_ID', '1234')
23+
monkeypatch.setenv("GA_TRACKING_ID", "1234")
2424

2525
import main
2626

@@ -31,17 +31,15 @@ def app(monkeypatch):
3131
@responses.activate
3232
def test_tracking(app):
3333
responses.add(
34-
responses.POST,
35-
re.compile(r'.*'),
36-
body='{}',
37-
content_type='application/json')
34+
responses.POST, re.compile(r".*"), body="{}", content_type="application/json"
35+
)
3836

39-
r = app.get('/')
37+
r = app.get("/")
4038

4139
assert r.status_code == 200
42-
assert 'Event tracked' in r.data.decode('utf-8')
40+
assert "Event tracked" in r.data.decode("utf-8")
4341

4442
assert len(responses.calls) == 1
4543
request_body = responses.calls[0].request.body
46-
assert 'tid=1234' in request_body
47-
assert 'ea=test+action' in request_body
44+
assert "tid=1234" in request_body
45+
assert "ea=test+action" in request_body

appengine/flexible/datastore/main.py

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,50 +33,59 @@ def is_ipv6(addr):
3333

3434

3535
# [START gae_flex_datastore_app]
36-
@app.route('/')
36+
@app.route("/")
3737
def index():
3838
ds = datastore.Client()
3939

4040
user_ip = request.remote_addr
4141

4242
# Keep only the first two octets of the IP address.
4343
if is_ipv6(user_ip):
44-
user_ip = ':'.join(user_ip.split(':')[:2])
44+
user_ip = ":".join(user_ip.split(":")[:2])
4545
else:
46-
user_ip = '.'.join(user_ip.split('.')[:2])
46+
user_ip = ".".join(user_ip.split(".")[:2])
4747

48-
entity = datastore.Entity(key=ds.key('visit'))
49-
entity.update({
50-
'user_ip': user_ip,
51-
'timestamp': datetime.datetime.now(tz=datetime.timezone.utc)
52-
})
48+
entity = datastore.Entity(key=ds.key("visit"))
49+
entity.update(
50+
{
51+
"user_ip": user_ip,
52+
"timestamp": datetime.datetime.now(tz=datetime.timezone.utc),
53+
}
54+
)
5355

5456
ds.put(entity)
55-
query = ds.query(kind='visit', order=('-timestamp',))
57+
query = ds.query(kind="visit", order=("-timestamp",))
5658

5759
results = []
5860
for x in query.fetch(limit=10):
5961
try:
60-
results.append('Time: {timestamp} Addr: {user_ip}'.format(**x))
62+
results.append("Time: {timestamp} Addr: {user_ip}".format(**x))
6163
except KeyError:
6264
print("Error with result format, skipping entry.")
6365

64-
output = 'Last 10 visits:\n{}'.format('\n'.join(results))
66+
output = "Last 10 visits:\n{}".format("\n".join(results))
67+
68+
return output, 200, {"Content-Type": "text/plain; charset=utf-8"}
69+
6570

66-
return output, 200, {'Content-Type': 'text/plain; charset=utf-8'}
6771
# [END gae_flex_datastore_app]
6872

6973

7074
@app.errorhandler(500)
7175
def server_error(e):
72-
logging.exception('An error occurred during a request.')
73-
return """
76+
logging.exception("An error occurred during a request.")
77+
return (
78+
"""
7479
An internal error occurred: <pre>{}</pre>
7580
See logs for full stacktrace.
76-
""".format(e), 500
81+
""".format(
82+
e
83+
),
84+
500,
85+
)
7786

7887

79-
if __name__ == '__main__':
88+
if __name__ == "__main__":
8089
# This is used when running locally. Gunicorn is used to run the
8190
# application on Google App Engine. See entrypoint in app.yaml.
82-
app.run(host='127.0.0.1', port=8080, debug=True)
91+
app.run(host="127.0.0.1", port=8080, debug=True)

appengine/flexible/datastore/main_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ def test_index():
1919
main.app.testing = True
2020
client = main.app.test_client()
2121

22-
r = client.get('/', environ_base={'REMOTE_ADDR': '127.0.0.1'})
22+
r = client.get("/", environ_base={"REMOTE_ADDR": "127.0.0.1"})
2323
assert r.status_code == 200
24-
assert 'Last 10 visits' in r.data.decode('utf-8')
24+
assert "Last 10 visits" in r.data.decode("utf-8")

appengine/flexible/disk/main.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ def index():
6969

7070
output = f"Instance: {instance_id}\nSeen:{seen}"
7171
return output, 200, {"Content-Type": "text/plain; charset=utf-8"}
72+
73+
7274
# [END example]
7375

7476

appengine/flexible/django_cloudsql/noxfile_config.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,14 @@
2222

2323
TEST_CONFIG_OVERRIDE = {
2424
# You can opt out from the test for specific Python versions.
25-
'ignored_versions': ["2.7"],
26-
25+
"ignored_versions": ["2.7"],
2726
# An envvar key for determining the project id to use. Change it
2827
# to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a
2928
# build specific Cloud project. You can also use your own string
3029
# to use your own Cloud project.
31-
'gcloud_project_env': 'GOOGLE_CLOUD_PROJECT',
30+
"gcloud_project_env": "GOOGLE_CLOUD_PROJECT",
3231
# 'gcloud_project_env': 'BUILD_SPECIFIC_GCLOUD_PROJECT',
33-
3432
# A dictionary you want to inject into your test. Don't put any
3533
# secrets here. These values will override predefined values.
36-
'envs': {
37-
'DJANGO_SETTINGS_MODULE': 'mysite.settings'
38-
},
34+
"envs": {"DJANGO_SETTINGS_MODULE": "mysite.settings"},
3935
}

appengine/flexible/django_cloudsql/polls/apps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616

1717

1818
class PollsConfig(AppConfig):
19-
name = 'polls'
19+
name = "polls"

appengine/flexible/django_cloudsql/polls/models.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@
1717

1818
class Question(models.Model):
1919
question_text = models.CharField(max_length=200)
20-
pub_date = models.DateTimeField('date published')
20+
pub_date = models.DateTimeField("date published")
2121

2222

2323
class Choice(models.Model):
2424
question = models.ForeignKey(Question, on_delete=models.CASCADE)
2525
choice_text = models.CharField(max_length=200)
2626
votes = models.IntegerField(default=0)
2727

28+
2829
# Create your models here.

appengine/flexible/django_cloudsql/polls/test_polls.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717

1818
class PollViewTests(TestCase):
1919
def test_index_view(self):
20-
response = self.client.get('/')
20+
response = self.client.get("/")
2121
assert response.status_code == 200
22-
assert 'Hello, world' in str(response.content)
22+
assert "Hello, world" in str(response.content)

appengine/flexible/django_cloudsql/polls/urls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@
1717
from . import views
1818

1919
urlpatterns = [
20-
re_path(r'^$', views.index, name='index'),
20+
re_path(r"^$", views.index, name="index"),
2121
]

0 commit comments

Comments
 (0)