Skip to content

Commit

Permalink
Use both black and flake8 in linting, flake8 clean
Browse files Browse the repository at this point in the history
  • Loading branch information
obscurerichard committed Feb 4, 2024
1 parent d636fa6 commit 93f56f9
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 41 deletions.
12 changes: 0 additions & 12 deletions .github/workflows/black.yml

This file was deleted.

25 changes: 25 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
# Thanks https://black.readthedocs.io/en/stable/integrations/github_actions.html
name: Lint

on: [push, pull_request]

jobs:
black-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: psf/[email protected]

flake8-lint:
runs-on: ubuntu-latest
name: Lint
steps:
- name: Check out source repository
uses: actions/checkout@v3
- name: Set up Python environment
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: flake8 Lint
uses: py-actions/flake8@v2
4 changes: 2 additions & 2 deletions freezing/web/utils/wktutils.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import re
from collections import namedtuple

_point_rx = re.compile("^POINT\((.+)\)$")
_linestring_rx = re.compile("^LINESTRING\((.+)\)$")
_point_rx = re.compile(r"^POINT\((.+)\)$")
_linestring_rx = re.compile(r"^LINESTRING\((.+)\)$")

LonLat = namedtuple("LonLat", ["lon", "lat"])

Expand Down
53 changes: 27 additions & 26 deletions freezing/web/views/chartdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,6 @@ def indiv_after_sunset():
@blueprint.route("/user_daily_points/<athlete_id>")
def user_daily_points(athlete_id):
""" """
teams = meta.scoped_session().query(Team).all() # @UndefinedVariable
day_q = text(
"""
select DS.points
Expand Down Expand Up @@ -898,7 +897,6 @@ def indiv_elev_dist():

rows = []
for i, res in enumerate(indiv_q):
place = i + 1
name_parts = res["athlete_name"].split(" ")
if len(name_parts) > 1:
short_name = " ".join([name_parts[0], name_parts[-1]])
Expand Down Expand Up @@ -974,12 +972,6 @@ def distance_by_lowtemp():
"""
)

cols = [
{"id": "date", "label": "Date", "type": "date"},
{"id": "distance", "label": "Distance", "type": "number"},
{"id": "day_temp_min", "label": "Low Temp", "type": "number"},
]

rows = []
for res in meta.scoped_session().execute(q): # @UndefinedVariable
if res["low_temp"] is None:
Expand Down Expand Up @@ -1088,12 +1080,15 @@ def parameterized_suffering_query(
@blueprint.route("/indiv_coldest")
def indiv_coldest():
q = text(parameterized_suffering_query("ride_temp_start", "temp_start", func="min"))
hl = lambda res, ql: "%.2f F for %s on %s in %s" % (
res["temp_start"],
fmt_dur(res["moving"]),
fmt_date(res["date"]),
res["loc"],
)

def hl(res, ql):
"%.2f F for %s on %s in %s" % (
res["temp_start"],
fmt_dur(res["moving"]),
fmt_date(res["date"]),
res["loc"],
)

return exec_and_jsonify_query(q, "Temperature", "temp_start", hover_lambda=hl)


Expand All @@ -1108,12 +1103,15 @@ def indiv_snowiest():
superlative_restriction="W2.ride_snow=1",
)
)
hl = lambda res, ql: "%.2f in for %s on %s in %s" % (
res["snow"],
fmt_dur(res["moving"]),
fmt_date(res["date"]),
res["loc"],
)

def hl(res, ql):
"%.2f in for %s on %s in %s" % (
res["snow"],
fmt_dur(res["moving"]),
fmt_date(res["date"]),
res["loc"],
)

return exec_and_jsonify_query(q, "Snowfall", "snow", hover_lambda=hl)


Expand All @@ -1128,10 +1126,13 @@ def indiv_rainiest():
superlative_restriction="W2.ride_rain=1",
)
)
hl = lambda res, ql: "%.2f in for %s on %s in %s" % (
res["rain"],
fmt_dur(res["moving"]),
fmt_date(res["date"]),
res["loc"],
)

def hl(res, ql):
"%.2f in for %s on %s in %s" % (
res["rain"],
fmt_dur(res["moving"]),
fmt_date(res["date"]),
res["loc"],
)

return exec_and_jsonify_query(q, "Rainfall", "rain", hover_lambda=hl)
2 changes: 1 addition & 1 deletion freezing/web/views/pointless.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ def pointlesskids():
rs = meta.scoped_session().execute(q)
d = defaultdict(int)
for x in rs.fetchall():
for match in re.findall("(#withkid\w+)", x["name"]):
for match in re.findall(r"(#withkid\w+)", x["name"]):
d[match.replace("#withkid", "")] += x["distance"]
return render_template(
"pointless/pointlesskids.html",
Expand Down

0 comments on commit 93f56f9

Please sign in to comment.