Permalink
Browse files

Our code is now flake8-compatible with import-order-shit

  • Loading branch information...
1 parent e5fd365 commit d2a72ba111e64740f8ed303c6c4827c220181bcf @pajlada committed Mar 8, 2016
Showing with 509 additions and 350 deletions.
  1. +4 −1 .flake8
  2. +3 −0 .isort.cfg
  3. +2 −4 .travis.yml
  4. +10 −10 app.py
  5. +2 −3 main.py
  6. +4 −3 pajbot/apiwrappers.py
  7. +1 −1 pajbot/bot.py
  8. +4 −4 pajbot/dispatch.py
  9. +1 −0 pajbot/managers/redis.py
  10. +1 −1 pajbot/models/action.py
  11. +11 −5 pajbot/models/banphrase.py
  12. +2 −1 pajbot/models/cachedvalue.py
  13. +21 −13 pajbot/models/command.py
  14. +8 −6 pajbot/models/connection.py
  15. +3 −3 pajbot/models/db.py
  16. +10 −7 pajbot/models/deck.py
  17. +9 −6 pajbot/models/duel.py
  18. +15 −10 pajbot/models/emote.py
  19. +12 −8 pajbot/models/filter.py
  20. +1 −1 pajbot/models/handler.py
  21. +5 −2 pajbot/models/hsbet.py
  22. +5 −2 pajbot/models/kvi.py
  23. +7 −4 pajbot/models/module.py
  24. +9 −4 pajbot/models/pleblist.py
  25. +2 −2 pajbot/models/sock.py
  26. +17 −11 pajbot/models/stream.py
  27. +1 −0 pajbot/models/time.py
  28. +10 −6 pajbot/models/timer.py
  29. +8 −4 pajbot/models/twitter.py
  30. +13 −8 pajbot/models/user.py
  31. +5 −2 pajbot/models/webcontent.py
  32. +9 −7 pajbot/models/whisperconnection.py
  33. +2 −1 pajbot/modules/ascii.py
  34. +5 −4 pajbot/modules/banphrase.py
  35. +5 −4 pajbot/modules/bingo.py
  36. +5 −4 pajbot/modules/blackjack.py
  37. +2 −1 pajbot/modules/deck.py
  38. +7 −5 pajbot/modules/duel.py
  39. +2 −1 pajbot/modules/dummy.py
  40. +5 −3 pajbot/modules/eightball.py
  41. +1 −1 pajbot/modules/emotecombo.py
  42. +2 −1 pajbot/modules/emotesonscreen.py
  43. +4 −3 pajbot/modules/followage.py
  44. +2 −1 pajbot/modules/givepoints.py
  45. +6 −4 pajbot/modules/highlight.py
  46. +10 −8 pajbot/modules/hsbet.py
  47. +4 −2 pajbot/modules/lastfm.py
  48. +4 −2 pajbot/modules/leaguerank.py
  49. +2 −1 pajbot/modules/linefarming.py
  50. +17 −11 pajbot/modules/linkchecker.py
  51. +9 −6 pajbot/modules/linktracker.py
  52. +6 −4 pajbot/modules/math.py
  53. +2 −1 pajbot/modules/maxmsglength.py
  54. +2 −1 pajbot/modules/paidsubmode.py
  55. +3 −2 pajbot/modules/paidtimeout.py
  56. +2 −1 pajbot/modules/pointlottery.py
  57. +12 −6 pajbot/modules/predict.py
  58. +2 −1 pajbot/modules/pyramid.py
  59. +3 −3 pajbot/modules/quest.py
  60. +1 −1 pajbot/modules/quests/base.py
  61. +1 −1 pajbot/modules/quests/gettimedout.py
  62. +4 −4 pajbot/modules/quests/typeemote.py
  63. +4 −4 pajbot/modules/quests/winduelpoints.py
  64. +2 −2 pajbot/modules/quests/winraffle.py
  65. +6 −4 pajbot/modules/raffle.py
  66. +6 −4 pajbot/modules/roulette.py
  67. +2 −1 pajbot/modules/subalert.py
  68. +3 −2 pajbot/modules/tokencommands/playsound.py
  69. +1 −1 pajbot/modules/tokencommands/showemote.py
  70. +2 −1 pajbot/modules/vanish.py
  71. +3 −1 pajbot/modules/warning.py
  72. +7 −3 pajbot/scripts/transfer-num-lines.py
  73. +2 −1 pajbot/scripts/update_emotes.py
  74. +1 −0 pajbot/streamhelper.py
  75. +1 −1 pajbot/tbmath.py
  76. +6 −5 pajbot/tbutil.py
  77. +3 −1 pajbot/web/common/assets.py
  78. +1 −0 pajbot/web/common/filters.py
  79. +1 −1 pajbot/web/common/tasks.py
  80. +1 −1 pajbot/web/models/thumbnail.py
  81. +6 −5 pajbot/web/routes/admin/banphrases.py
  82. +8 −6 pajbot/web/routes/admin/commands.py
  83. +2 −2 pajbot/web/routes/admin/home.py
  84. +2 −2 pajbot/web/routes/admin/links.py
  85. +2 −1 pajbot/web/routes/admin/moderators.py
  86. +5 −3 pajbot/web/routes/admin/modules.py
  87. +6 −4 pajbot/web/routes/admin/predictions.py
  88. +2 −2 pajbot/web/routes/admin/streamer.py
  89. +5 −5 pajbot/web/routes/admin/timers.py
  90. +24 −22 pajbot/web/routes/api.py
  91. +2 −1 pajbot/web/routes/base/commands.py
  92. +1 −0 pajbot/web/routes/base/contact.py
  93. +2 −1 pajbot/web/routes/base/decks.py
  94. +6 −4 pajbot/web/routes/base/highlights.py
  95. +2 −2 pajbot/web/routes/base/home.py
  96. +8 −8 pajbot/web/routes/base/login.py
  97. +1 −0 pajbot/web/routes/base/notifications.py
  98. +5 −3 pajbot/web/routes/base/pleblist.py
  99. +4 −4 pajbot/web/routes/base/points.py
  100. +3 −2 pajbot/web/routes/base/stats.py
  101. +3 −3 pajbot/web/routes/base/user.py
  102. +1 −1 pajbot/web/routes/clr.py
  103. +7 −7 pajbot/web/utils.py
  104. +3 −2 tests/tests.py
View
@@ -1,6 +1,8 @@
[flake8]
exclude = alembic/*,configs/*,install/*,myvenv/*,node_modules/*,pajbot/scripts/*,__pycache__/*,requirements/*,static/*,templates/*,uwsgiconfigs/*,.git/*,userdispatch.py,src/*,__init__.py
-ignore = E123,E126,E127,E128,E302,E501,F401
+ignore = E123,E126,E127,E128,E302,E501,F401,I101
+application-import-names = pajbot
+import-order-style = smarkets
# E123 = closing bracket does not match indentation of opening bracket’s line
# E126 = continuation line over-indented for hanging indent
@@ -9,3 +11,4 @@ ignore = E123,E126,E127,E128,E302,E501,F401
# E302 = expected 2 blank lines, found 0
# E501 = line too long (82 > 79 characters)
# F401 = module imported but unused
+# I101 = The names in your from import are in wrong order
View
@@ -0,0 +1,3 @@
+[settings]
+known_standard_library=queue
+force_single_line = True
View
@@ -2,9 +2,7 @@
language: python
sudo: false
-cache:
- directories:
- - $HOME/.cache/pip
+cache: pip
python:
- 3.4
@@ -15,7 +13,7 @@ services:
before_install:
- mysql -e "create database IF NOT EXISTS test;" -uroot
- - pip install pip flake8 flake8-quotes --upgrade
+ - pip install pip flake8 flake8-quotes flake8-import-order --upgrade
- flake8
install:
View
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
-
import argparse
import configparser
import datetime
@@ -8,23 +7,24 @@
import subprocess
import sys
+from flask import Flask
+from flask import request
+from flask import session
+from flask.ext.scrypt import generate_random_salt
+
+import pajbot.web.common
+import pajbot.web.routes
from pajbot.bot import Bot
from pajbot.managers import RedisManager
from pajbot.models.db import DBManager
from pajbot.models.module import ModuleManager
from pajbot.models.sock import SocketClientManager
from pajbot.models.time import TimeManager
from pajbot.streamhelper import StreamHelper
-from pajbot.tbutil import load_config, init_logging
-from pajbot.web.utils import download_logo
+from pajbot.tbutil import init_logging
+from pajbot.tbutil import load_config
from pajbot.web.models import errors
-import pajbot.web.routes
-import pajbot.web.common
-
-from flask import Flask
-from flask import request
-from flask import session
-from flask.ext.scrypt import generate_random_salt
+from pajbot.web.utils import download_logo
init_logging('pajbot')
log = logging.getLogger('pajbot')
View
@@ -1,9 +1,8 @@
#!/usr/bin/env python3
-
+import logging
import os
-import sys
import signal
-import logging
+import sys
from pajbot.bot import Bot
@@ -1,9 +1,10 @@
-import urllib.parse
-import urllib.request
+import datetime
import json
import logging
+import urllib.parse
+import urllib.request
+
import requests
-import datetime
from pajbot.managers import RedisManager
View
@@ -7,9 +7,9 @@
import time
import urllib
+import irc.client
from numpy import random
from pytz import timezone
-import irc.client
from pajbot.actions import ActionQueue
from pajbot.apiwrappers import TwitchAPI
View
@@ -1,13 +1,13 @@
-import re
-import logging
import collections
import datetime
-
-from pajbot.models.user import User
+import logging
+import re
from sqlalchemy import desc
from sqlalchemy import func
+from pajbot.models.user import User
+
log = logging.getLogger('pajbot')
@@ -1,5 +1,6 @@
import redis
+
class RedisManager:
"""
Responsible for making sure exactly one instance of Redis
@@ -1,6 +1,6 @@
+import collections
import json
import logging
-import collections
import irc
import regex as re
@@ -1,12 +1,18 @@
-import logging
import argparse
-
-from pajbot.tbutil import find
-from pajbot.models.db import DBManager, Base
+import logging
import sqlalchemy
+from sqlalchemy import Boolean
+from sqlalchemy import Column
+from sqlalchemy import Enum
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import String
from sqlalchemy.orm import relationship
-from sqlalchemy import Column, Integer, Boolean, ForeignKey, String, Enum
+
+from pajbot.models.db import Base
+from pajbot.models.db import DBManager
+from pajbot.tbutil import find
log = logging.getLogger('pajbot')
@@ -1,6 +1,7 @@
import logging
import threading
-from datetime import datetime, timedelta
+from datetime import datetime
+from datetime import timedelta
log = logging.getLogger('pajbot')
@@ -1,19 +1,27 @@
-import json
-import time
-import logging
-from collections import UserDict
import argparse
import datetime
+import json
+import logging
import re
+import time
+from collections import UserDict
-from pajbot.tbutil import find
-from pajbot.models.db import DBManager, Base
-from pajbot.models.action import ActionParser, RawFuncAction
-
-from sqlalchemy import orm
-from sqlalchemy.orm import relationship, joinedload
-from sqlalchemy import Column, Integer, Boolean, DateTime, ForeignKey, String
+from sqlalchemy import Boolean
+from sqlalchemy import Column
+from sqlalchemy import DateTime
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import String
from sqlalchemy.dialects.mysql import TEXT
+from sqlalchemy.orm import joinedload
+from sqlalchemy.orm import reconstructor
+from sqlalchemy.orm import relationship
+
+from pajbot.models.action import ActionParser
+from pajbot.models.action import RawFuncAction
+from pajbot.models.db import Base
+from pajbot.models.db import DBManager
+from pajbot.tbutil import find
log = logging.getLogger('pajbot')
@@ -125,7 +133,7 @@ def __init__(self, command_id, title, chat='', description=''):
self.description = description
self.chat_messages = []
- @orm.reconstructor
+ @reconstructor
def init_on_load(self):
self.parse()
@@ -248,7 +256,7 @@ def set(self, **options):
self.mod_only = options.get('mod_only', self.mod_only)
self.examples = options.get('examples', self.examples)
- @orm.reconstructor
+ @reconstructor
def init_on_load(self):
self.last_run = 0
self.last_run_by_user = {}
@@ -1,12 +1,14 @@
-import urllib
-import random
import logging
-
-import pajbot.tbutil
+import random
+import socket
+import urllib
import irc
-from irc.client import InvalidCharacters, MessageTooLong, ServerNotConnectedError
-import socket
+from irc.client import InvalidCharacters
+from irc.client import MessageTooLong
+from irc.client import ServerNotConnectedError
+
+import pajbot.tbutil
log = logging.getLogger('pajbot')
View
@@ -2,10 +2,10 @@
from contextlib import contextmanager
from sqlalchemy import create_engine
-from sqlalchemy.orm import sessionmaker
-from sqlalchemy.orm import scoped_session
-from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import inspect
+from sqlalchemy.ext.declarative import declarative_base
+from sqlalchemy.orm import scoped_session
+from sqlalchemy.orm import sessionmaker
Base = declarative_base()
View
@@ -1,13 +1,16 @@
-import logging
-import datetime
import argparse
+import datetime
+import logging
from collections import UserList
-from pajbot.tbutil import time_ago
-from pajbot.models.db import DBManager, Base
+from sqlalchemy import Column
+from sqlalchemy import DateTime
+from sqlalchemy import Integer
+from sqlalchemy import String
-from sqlalchemy import Column, Integer, String, DateTime
-from sqlalchemy import desc
+from pajbot.models.db import Base
+from pajbot.models.db import DBManager
+from pajbot.tbutil import time_ago
log = logging.getLogger('pajbot')
@@ -131,7 +134,7 @@ def commit(self):
def reload(self):
self.data = []
- for deck in self.db_session.query(Deck).order_by(desc(Deck.last_used)):
+ for deck in self.db_session.query(Deck).order_by(Deck.last_used.desc()):
if self.current_deck is None:
self.current_deck = deck
self.data.append(deck)
View
@@ -1,12 +1,15 @@
-import logging
import datetime
+import logging
-from pajbot.models.db import Base
-
-from sqlalchemy import Column, Integer, DateTime, ForeignKey
-from sqlalchemy.orm import relationship
-from sqlalchemy.orm import backref
+from sqlalchemy import Column
+from sqlalchemy import DateTime
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
from sqlalchemy.ext.hybrid import hybrid_property
+from sqlalchemy.orm import backref
+from sqlalchemy.orm import relationship
+
+from pajbot.models.db import Base
log = logging.getLogger('pajbot')
@@ -1,16 +1,21 @@
-import logging
import datetime
-from collections import UserDict
-import re
import json
+import logging
+import re
+from collections import UserDict
-from pajbot.models.db import DBManager, Base
-from pajbot.apiwrappers import APIBase
-
-from sqlalchemy import orm
-from sqlalchemy import Column, Integer, String, DateTime, ForeignKey
+from sqlalchemy import Column
+from sqlalchemy import DateTime
+from sqlalchemy import ForeignKey
+from sqlalchemy import Integer
+from sqlalchemy import String
+from sqlalchemy.orm import reconstructor
from sqlalchemy.orm import relationship
+from pajbot.apiwrappers import APIBase
+from pajbot.models.db import Base
+from pajbot.models.db import DBManager
+
log = logging.getLogger('pajbot')
@@ -36,7 +41,7 @@ def __init__(self, manager, emote_id=None, emote_hash=None, code=None):
else:
self.regex = None
- @orm.reconstructor
+ @reconstructor
def init_on_load(self):
if self.emote_id is None:
self.regex = re.compile('(?<![^ ]){0}(?![^ ])'.format(re.escape(self.code)))
@@ -81,7 +86,7 @@ def __init__(self, emote_code):
self.tm = 0
- @orm.reconstructor
+ @reconstructor
def init_on_load(self):
self.tm = 0
Oops, something went wrong.

0 comments on commit d2a72ba

Please sign in to comment.