mirror of
https://gitlab.com/SIGBUS/nyaa.git
synced 2024-12-22 03:49:59 +00:00
Apply isort & flake8 (#312)
* Update isort settings * Apply import sorting (isort) on all files in nyaa/ * Fixed Flake8 errors in nyaa/ (see PR for list) * Add isort to lint.sh and requirements.txt
This commit is contained in:
parent
99c052c85f
commit
b992467dad
12
lint.sh
12
lint.sh
|
@ -1,6 +1,7 @@
|
|||
# Lint checker/fixer
|
||||
|
||||
check_paths="nyaa/ utils/"
|
||||
isort_paths="nyaa/" # just nyaa/ for now
|
||||
max_line_length=100
|
||||
|
||||
function auto_pep8() {
|
||||
|
@ -9,14 +10,21 @@ function auto_pep8() {
|
|||
--in-place \
|
||||
--pep8-passes 2000 \
|
||||
--max-line-length ${max_line_length} \
|
||||
--verbose
|
||||
--verbose \
|
||||
&& \
|
||||
isort ${isort_paths}
|
||||
}
|
||||
|
||||
function check_lint() {
|
||||
pycodestyle ${check_paths} \
|
||||
--show-source \
|
||||
--max-line-length=${max_line_length} \
|
||||
--format '%(path)s [%(row)s:%(col)s] %(code)s: %(text)s'
|
||||
--format '%(path)s [%(row)s:%(col)s] %(code)s: %(text)s' \
|
||||
&& \
|
||||
isort ${isort_paths} \
|
||||
--recursive \
|
||||
--diff \
|
||||
--check-only
|
||||
}
|
||||
|
||||
# MAIN
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
import os
|
||||
import logging
|
||||
import flask
|
||||
from flask_sqlalchemy import SQLAlchemy
|
||||
from flask_assets import Environment, Bundle
|
||||
from flask_debugtoolbar import DebugToolbarExtension
|
||||
from nyaa import fix_paginate
|
||||
import os
|
||||
|
||||
import flask
|
||||
from flask_assets import Bundle, Environment # noqa F401
|
||||
from flask_debugtoolbar import DebugToolbarExtension
|
||||
from flask_sqlalchemy import SQLAlchemy
|
||||
|
||||
from nyaa import fix_paginate # noqa F401
|
||||
|
||||
app = flask.Flask(__name__)
|
||||
app.config.from_object('config')
|
||||
|
@ -70,4 +71,4 @@ assets = Environment(app)
|
|||
# output='style.css', depends='**/*.scss')
|
||||
# assets.register('style_all', css)
|
||||
|
||||
from nyaa import routes # noqa E402
|
||||
from nyaa import routes # noqa E402 isort:skip
|
||||
|
|
|
@ -1,19 +1,13 @@
|
|||
import flask
|
||||
from werkzeug.datastructures import ImmutableMultiDict, CombinedMultiDict
|
||||
|
||||
from nyaa import app, db
|
||||
from nyaa import models, forms
|
||||
from nyaa import bencode, backend, utils
|
||||
from nyaa import torrents
|
||||
|
||||
from nyaa.views.torrents import _create_upload_category_choices
|
||||
|
||||
import binascii
|
||||
import functools
|
||||
import json
|
||||
import os.path
|
||||
import re
|
||||
|
||||
import binascii
|
||||
import flask
|
||||
|
||||
from nyaa import backend, bencode, db, forms, models, utils
|
||||
from nyaa.views.torrents import _create_upload_category_choices
|
||||
|
||||
api_blueprint = flask.Blueprint('api', __name__)
|
||||
|
||||
|
@ -124,7 +118,7 @@ def v2_api_upload():
|
|||
|
||||
# #################################### TEMPORARY ####################################
|
||||
|
||||
from orderedset import OrderedSet # noqa: E402
|
||||
from orderedset import OrderedSet # noqa: E402 isort:skip
|
||||
|
||||
|
||||
@api_blueprint.route('/ghetto_import', methods=['POST'])
|
||||
|
@ -146,7 +140,7 @@ def ghetto_import():
|
|||
return 'Malformed torrent metadata ({})'.format(e.args[0]), 500
|
||||
|
||||
try:
|
||||
tracker_found = forms._validate_trackers(torrent_dict)
|
||||
tracker_found = forms._validate_trackers(torrent_dict) # noqa F841
|
||||
except AssertionError as e:
|
||||
return 'Malformed torrent trackers ({})'.format(e.args[0]), 500
|
||||
|
||||
|
|
|
@ -1,16 +1,14 @@
|
|||
import flask
|
||||
from nyaa import app, db
|
||||
from nyaa import models, forms
|
||||
from nyaa import bencode, utils
|
||||
|
||||
import os
|
||||
|
||||
import json
|
||||
from werkzeug import secure_filename
|
||||
from collections import OrderedDict
|
||||
from orderedset import OrderedSet
|
||||
import os
|
||||
from ipaddress import ip_address
|
||||
|
||||
import flask
|
||||
from werkzeug import secure_filename
|
||||
|
||||
from orderedset import OrderedSet
|
||||
|
||||
from nyaa import app, db, models, utils
|
||||
|
||||
|
||||
@utils.cached_function
|
||||
def get_category_id_map():
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import sqlalchemy
|
||||
from flask_sqlalchemy import Pagination, BaseQuery
|
||||
from flask import abort
|
||||
from flask_sqlalchemy import BaseQuery, Pagination
|
||||
|
||||
|
||||
def paginate_faste(self, page=1, per_page=50, max_page=None, step=5, count_query=None):
|
||||
|
|
|
@ -1,25 +1,21 @@
|
|||
import flask
|
||||
from nyaa import db, app
|
||||
from nyaa.models import User
|
||||
from nyaa import bencode, utils, models
|
||||
|
||||
import functools
|
||||
import os
|
||||
import re
|
||||
import functools
|
||||
|
||||
import flask
|
||||
from flask_wtf import FlaskForm
|
||||
from flask_wtf.file import FileField, FileRequired
|
||||
from wtforms import StringField, PasswordField, BooleanField, TextAreaField, SelectField,\
|
||||
HiddenField
|
||||
from wtforms.validators import DataRequired, Optional, Email, Length, EqualTo, ValidationError,\
|
||||
StopValidation
|
||||
from wtforms.validators import Regexp
|
||||
|
||||
# For DisabledSelectField
|
||||
from wtforms.widgets import Select as SelectWidget
|
||||
from wtforms.widgets import html_params, HTMLString
|
||||
|
||||
from flask_wtf.recaptcha import RecaptchaField
|
||||
from flask_wtf.recaptcha.validators import Recaptcha as RecaptchaValidator
|
||||
from wtforms import (BooleanField, HiddenField, PasswordField, SelectField, StringField,
|
||||
TextAreaField)
|
||||
from wtforms.validators import (DataRequired, Email, EqualTo, Length, Optional, Regexp,
|
||||
StopValidation, ValidationError)
|
||||
from wtforms.widgets import Select as SelectWidget # For DisabledSelectField
|
||||
from wtforms.widgets import HTMLString, html_params # For DisabledSelectField
|
||||
|
||||
from nyaa import app, bencode, models, utils
|
||||
from nyaa.models import User
|
||||
|
||||
|
||||
class Unique(object):
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
import flask
|
||||
import base64
|
||||
import re
|
||||
from datetime import datetime
|
||||
from enum import Enum, IntEnum
|
||||
from datetime import datetime, timezone
|
||||
from hashlib import md5
|
||||
from ipaddress import ip_address
|
||||
from urllib.parse import unquote as unquote_url
|
||||
from urllib.parse import urlencode
|
||||
|
||||
import flask
|
||||
from markupsafe import escape as escape_markup
|
||||
|
||||
from sqlalchemy import ForeignKeyConstraint, Index
|
||||
from sqlalchemy.ext import declarative
|
||||
from sqlalchemy_fulltext import FullText
|
||||
from sqlalchemy_utils import ChoiceType, EmailType, PasswordType
|
||||
|
||||
from nyaa import app, db
|
||||
from nyaa.torrents import create_magnet
|
||||
|
||||
from sqlalchemy import func, ForeignKeyConstraint, Index
|
||||
from sqlalchemy.ext import declarative
|
||||
from sqlalchemy_utils import ChoiceType, EmailType, PasswordType
|
||||
from sqlalchemy_fulltext import FullText
|
||||
|
||||
from werkzeug.security import generate_password_hash, check_password_hash
|
||||
from ipaddress import ip_address
|
||||
|
||||
import re
|
||||
import base64
|
||||
from markupsafe import escape as escape_markup
|
||||
from urllib.parse import urlencode, unquote as unquote_url
|
||||
from hashlib import md5
|
||||
|
||||
if app.config['USE_MYSQL']:
|
||||
from sqlalchemy.dialects import mysql
|
||||
BinaryType = mysql.BINARY
|
||||
|
|
|
@ -1,17 +1,16 @@
|
|||
import flask
|
||||
import re
|
||||
import math
|
||||
import json
|
||||
import re
|
||||
import shlex
|
||||
|
||||
from nyaa import app, db
|
||||
from nyaa import models
|
||||
import flask
|
||||
|
||||
import sqlalchemy
|
||||
import sqlalchemy_fulltext.modes as FullTextMode
|
||||
from sqlalchemy_fulltext import FullTextSearch
|
||||
from elasticsearch import Elasticsearch
|
||||
from elasticsearch_dsl import Search, Q
|
||||
from elasticsearch_dsl import Q, Search
|
||||
from sqlalchemy_fulltext import FullTextSearch
|
||||
|
||||
from nyaa import app, db, models
|
||||
|
||||
DEFAULT_MAX_SEARCH_RESULT = 1000
|
||||
DEFAULT_PER_PAGE = 75
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
import os
|
||||
import base64
|
||||
import os
|
||||
import time
|
||||
from urllib.parse import urlencode
|
||||
from orderedset import OrderedSet
|
||||
from nyaa import app
|
||||
|
||||
from nyaa import bencode
|
||||
from nyaa import app
|
||||
from nyaa import models
|
||||
from orderedset import OrderedSet
|
||||
|
||||
from nyaa import app, bencode
|
||||
|
||||
USED_TRACKERS = OrderedSet()
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import hashlib
|
||||
import functools
|
||||
import hashlib
|
||||
from collections import OrderedDict
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from nyaa.views import (
|
||||
from nyaa.views import ( # isort:skip
|
||||
account,
|
||||
admin,
|
||||
main,
|
||||
|
|
|
@ -19,6 +19,7 @@ Flask-WTF==0.14.2
|
|||
gevent==1.2.1
|
||||
greenlet==0.4.12
|
||||
itsdangerous==0.24
|
||||
isort==4.2.15
|
||||
Jinja2==2.9.6
|
||||
libsass==0.12.3
|
||||
Mako==1.0.6
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
[isort]
|
||||
line_length = 100
|
||||
not_skip = __init__.py
|
||||
default_section = THIRDPARTY
|
||||
known_first_party = nyaa
|
||||
known_flask = flask, flask_wtf, flask_paginate, jinja2, werkzeug
|
||||
known_flask =
|
||||
flask*,
|
||||
jinja2,
|
||||
markupsafe,
|
||||
werkzeug,
|
||||
wtforms
|
||||
sections = STDLIB,FLASK,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
|
||||
|
|
Loading…
Reference in a new issue