Skip to content

Commit

Permalink
Add isort linting, isort clean
Browse files Browse the repository at this point in the history
  • Loading branch information
obscurerichard committed Feb 4, 2024
1 parent 93f56f9 commit 28f26c4
Show file tree
Hide file tree
Showing 25 changed files with 91 additions and 102 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
---
# Thanks https://black.readthedocs.io/en/stable/integrations/github_actions.html
name: Lint

on: [push, pull_request]

jobs:

# Thanks https://black.readthedocs.io/en/stable/integrations/github_actions.html
black-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: psf/[email protected]

isort-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: isort/isort-action@v1
with:
requirements-files: "requirements.txt requirements-test.txt"

flake8-lint:
runs-on: ubuntu-latest
name: Lint
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
*.cfg
*.egg-info
*.pyc
.*
.env*
.venv*
/*.iml
/build
/data/cache/*
Expand Down
14 changes: 7 additions & 7 deletions freezing/web/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from flask import Flask, session, g

from flask import Flask, g, session
from freezing.model import init_model, meta

from .config import config

# Thanks https://stackoverflow.com/a/17073583
Expand All @@ -11,16 +11,16 @@

# This needs to be after the app is created, unfortunately.
from freezing.web.views import ( # noqa
alt_scoring,
api,
chartdata,
general,
leaderboard,
chartdata,
people,
user,
pointless,
photos,
api,
alt_scoring,
pointless,
tribes,
user,
)

# Register our blueprints
Expand Down
3 changes: 2 additions & 1 deletion freezing/web/autolog.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import absolute_import
import logging

import inspect
import logging


class EagerFormattingAdapter(logging.LoggerAdapter):
Expand Down
8 changes: 3 additions & 5 deletions freezing/web/config.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import logging
import os
from typing import List
from datetime import datetime, tzinfo

from colorlog import ColoredFormatter
from envparse import env
from typing import List

import arrow
import pytz

from colorlog import ColoredFormatter
from envparse import env

envfile = os.environ.get("APP_SETTINGS", os.path.join(os.getcwd(), ".env"))

Expand Down
28 changes: 12 additions & 16 deletions freezing/web/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,35 @@
"""

from __future__ import division, unicode_literals
import re
import logging

from instagram import InstagramAPIError, InstagramClientError


from sqlalchemy import and_
from geoalchemy import WKTSpatialElement

from requests.exceptions import HTTPError

from stravalib import Client
from stravalib import model as strava_model
from stravalib import unithelper
import logging
import re

from freezing.model import meta, orm
from freezing.model.orm import (
Athlete,
Ride,
RideGeo,
RideEffort,
RideGeo,
RidePhoto,
RideTrack,
Team,
)
from geoalchemy import WKTSpatialElement
from instagram import InstagramAPIError, InstagramClientError
from requests.exceptions import HTTPError
from sqlalchemy import and_
from stravalib import Client
from stravalib import model as strava_model
from stravalib import unithelper

from freezing.web import config
from freezing.web.autolog import log
from freezing.web.exc import (
DataEntryError,
InvalidAuthorizationToken,
NoTeamsError,
MultipleTeamsError,
DataEntryError,
NoTeamsError,
)
from freezing.web.utils import insta, wktutils

Expand Down
5 changes: 2 additions & 3 deletions freezing/web/utils/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
"""

import logging
from functools import wraps, update_wrapper
from datetime import timedelta
from functools import update_wrapper, wraps

from flask import session, g
from flask import make_response, request, current_app
from flask import current_app, g, make_response, request, session
from werkzeug.exceptions import Forbidden


Expand Down
8 changes: 3 additions & 5 deletions freezing/web/utils/genericboard.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import decimal
import os
from datetime import datetime
from typing import List, Dict, Any, Tuple
from typing import Any, Dict, List, Tuple

import yaml

from marshmallow import fields

from freezing.model import meta
from freezing.model.msg import BaseSchema, BaseMessage
from freezing.model.msg import BaseMessage, BaseSchema
from marshmallow import fields

from freezing.web.config import config
from freezing.web.exc import ObjectNotFound
Expand Down
3 changes: 2 additions & 1 deletion freezing/web/utils/gviz_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@
import html # Python version 3.2 or higher
except ImportError:
import cgi as html # Only used for .escape()
import numbers

import json
import numbers

import six

Expand Down
4 changes: 1 addition & 3 deletions freezing/web/utils/hashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
from typing import List

import yaml

from freezing.model.msg import BaseMessage, BaseSchema
from marshmallow import fields

from freezing.model.msg import BaseSchema, BaseMessage

from freezing.web.config import config
from freezing.web.exc import ObjectNotFound

Expand Down
3 changes: 2 additions & 1 deletion freezing/web/utils/insta.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
"""

import os
import urllib
import shutil
import urllib

from instagram.client import InstagramAPI

from freezing.web import exc
from freezing.web.config import config

Expand Down
4 changes: 1 addition & 3 deletions freezing/web/utils/tribes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
from typing import List

import yaml

from freezing.model.msg import BaseMessage, BaseSchema
from marshmallow import fields

from freezing.model.msg import BaseSchema, BaseMessage

from freezing.web.config import config
from freezing.web.exc import ObjectNotFound

Expand Down
6 changes: 2 additions & 4 deletions freezing/web/views/alt_scoring.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
from collections import defaultdict
from itertools import groupby

from flask import render_template, Blueprint
from sqlalchemy import text
from statistics import median

from flask import Blueprint, render_template
from freezing.model import meta
from sqlalchemy import text

from freezing.web import config
from freezing.web.views.shared_sql import (
Expand All @@ -16,7 +15,6 @@
team_sleaze_query,
)


blueprint = Blueprint("alt_scoring", __name__)


Expand Down
9 changes: 4 additions & 5 deletions freezing/web/views/api.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import json
from datetime import timedelta
from decimal import Decimal
import json

import arrow
from flask import Blueprint, jsonify, request
import pytz
from sqlalchemy import text

from flask import Blueprint, jsonify, request
from freezing.model import meta
from freezing.model.orm import RidePhoto, Ride, RideTrack, Athlete
from freezing.model.orm import Athlete, Ride, RidePhoto, RideTrack
from sqlalchemy import text

from freezing.web import config
from freezing.web.autolog import log
Expand Down
17 changes: 7 additions & 10 deletions freezing/web/views/chartdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,30 @@
@author: hans
"""

import json
import copy
import json
from collections import defaultdict
from datetime import datetime, timedelta

from flask import current_app, Blueprint, jsonify

from sqlalchemy import text
from dateutil import rrule

from flask import Blueprint, current_app, jsonify
from freezing.model import meta
from freezing.model.orm import Team
from pytz import utc
from sqlalchemy import text

from freezing.web import config
from freezing.web.utils import gviz_api
from freezing.web.utils.dates import parse_competition_timestamp
from freezing.web.views.shared_sql import (
team_leaderboard_query,
indiv_sleaze_query,
team_sleaze_query,
indiv_freeze_query,
indiv_segment_query,
indiv_sleaze_query,
team_leaderboard_query,
team_segment_query,
team_sleaze_query,
)

from pytz import utc

blueprint = Blueprint("chartdata", __name__)


Expand Down
17 changes: 8 additions & 9 deletions freezing/web/views/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,23 @@
"""

from flask import (
render_template,
Blueprint,
jsonify,
redirect,
url_for,
render_template,
request,
Blueprint,
session,
jsonify,
url_for,
)
from freezing.model import meta
from freezing.model.orm import Ride, RidePhoto
from sqlalchemy import text
from stravalib import Client

from freezing.model import meta
from freezing.model.orm import RidePhoto, Ride

from freezing.web import app, data, config
from freezing.web.utils import auth
from freezing.web import app, config, data
from freezing.web.autolog import log
from freezing.web.exc import MultipleTeamsError, NoTeamsError
from freezing.web.utils import auth

blueprint = Blueprint("general", __name__)

Expand Down
4 changes: 2 additions & 2 deletions freezing/web/views/leaderboard.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from flask import url_for, render_template, Blueprint
from flask import Blueprint, render_template, url_for
from freezing.model import meta
from sqlalchemy import text
from werkzeug.utils import redirect

from freezing.model import meta
from freezing.web import config
from freezing.web.views.shared_sql import team_leaderboard_query

Expand Down
14 changes: 5 additions & 9 deletions freezing/web/views/people.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
from datetime import timedelta
from datetime import datetime

from flask import render_template, Blueprint, abort
from sqlalchemy import text
from datetime import datetime, timedelta

from flask import Blueprint, abort, render_template
from freezing.model import meta
from freezing.model.orm import Team, Athlete
from freezing.model.orm import Athlete, Team
from pytz import timezone, utc
from sqlalchemy import text

from freezing.web import config

from pytz import utc, timezone


blueprint = Blueprint("people", __name__)


Expand Down
7 changes: 3 additions & 4 deletions freezing/web/views/photos.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import math

from flask import render_template, Blueprint, send_file, request

from flask import Blueprint, render_template, request, send_file
from freezing.model import meta
from freezing.model.orm import RidePhoto, Ride
from freezing.model.orm import Ride, RidePhoto

from freezing.web import config
from freezing.web.utils import insta
from freezing.web.autolog import log
from freezing.web.utils import insta

blueprint = Blueprint("photos", __name__)

Expand Down
Loading

0 comments on commit 28f26c4

Please sign in to comment.