Move to Python 3.7 and update dependencies (#551)

* forms: replace re._pattern_type with re.Pattern

Python 3.7 removed re._pattern_type and replaced it with
re.Pattern.

* readme: update for Python 3.7

* Update requirements

Also remove some unused ones which were neither a direct dependency
nor a dependency of our dependencies.

* account: force ASCII usernames on login form

Our database doesn't like it when we check for unicode data in
a column that stores ASCII data, so let's stop it before it
gets that far.

* Move travis CI to Python 3.7

* travis: use xenial dist

* fix newer linter warnings

Apparently bare excepts are literally Hitler, and we have some
new import sorting rules. Hooray!

* requirements: remove six

This is a dependency for sqlalchemy-utils, but we ourselves don't
depend on it directly because we've never been on Python 2 ever.

* Update requirements.txt
nuke-comments
Nicolas F 4 years ago committed by Arylide
parent 16814d6eb7
commit d8e796f3e0

@ -1,8 +1,8 @@
language: python
python: "3.6"
python: "3.7"
dist: trusty
dist: xenial
sudo: required
matrix:

@ -1,7 +1,7 @@
# NyaaV2 [![Build Status](https://travis-ci.org/nyaadevs/nyaa.svg?branch=master)](https://travis-ci.org/nyaadevs/nyaa)
## Setting up for development
This project uses Python 3.6. There are features used that do not exist in 3.5, so make sure to use Python 3.6.
This project uses Python 3.7. There are features used that do not exist in 3.6, so make sure to use Python 3.7.
This guide also assumes you 1) are using Linux and 2) are somewhat capable with the commandline.
It's not impossible to run Nyaa on Windows, but this guide doesn't focus on that.
@ -16,13 +16,13 @@ The `tests` folder contains tests for the the `nyaa` module and the webserver. T
- Run `./dev.py test` while in the repository directory.
### Setting up Pyenv
pyenv eases the use of different Python versions, and as not all Linux distros offer 3.6 packages, it's right up our alley.
pyenv eases the use of different Python versions, and as not all Linux distros offer 3.7 packages, it's right up our alley.
- Install dependencies https://github.com/pyenv/pyenv/wiki/Common-build-problems
- Install `pyenv` https://github.com/pyenv/pyenv/blob/master/README.md#installation
- Install `pyenv-virtualenv` https://github.com/pyenv/pyenv-virtualenv/blob/master/README.md
- Install Python 3.6.1 with `pyenv` and create a virtualenv for the project:
- `pyenv install 3.6.1`
- `pyenv virtualenv 3.6.1 nyaa`
- Install Python 3.7.2 with `pyenv` and create a virtualenv for the project:
- `pyenv install 3.7.2`
- `pyenv virtualenv 3.7.2 nyaa`
- `pyenv activate nyaa`
- Install dependencies with `pip install -r requirements.txt`
- Copy `config.example.py` into `config.py`

@ -67,7 +67,7 @@ def _bencode_decode(file_object, decode_keys_as_utf8=True):
elif c == _B_END:
try:
return int(int_bytes.decode('utf8'))
except Exception as e:
except Exception:
raise create_ex('Unable to parse int')
# not a digit OR '-' in the middle of the int
@ -109,7 +109,7 @@ def _bencode_decode(file_object, decode_keys_as_utf8=True):
raise create_ex('Unexpected input while reading string length: ' + repr(c))
try:
str_len = int(str_len_bytes.decode())
except Exception as e:
except Exception:
raise create_ex('Unable to parse bytestring length')
bytestring = file_object.read(str_len)

@ -11,8 +11,9 @@ from wtforms import (BooleanField, HiddenField, PasswordField, SelectField, Stri
SubmitField, TextAreaField)
from wtforms.validators import (DataRequired, Email, EqualTo, Length, Optional, Regexp,
StopValidation, ValidationError)
from wtforms.widgets import HTMLString # For DisabledSelectField
from wtforms.widgets import Select as SelectWidget # For DisabledSelectField
from wtforms.widgets import HTMLString, html_params # For DisabledSelectField
from wtforms.widgets import html_params
import dns.exception
import dns.resolver
@ -78,7 +79,7 @@ def register_email_blacklist_validator(form, field):
validation_exception = StopValidation('Blacklisted email provider')
for item in email_blacklist:
if isinstance(item, re._pattern_type):
if isinstance(item, re.Pattern):
if item.search(email):
raise validation_exception
elif isinstance(item, str):

@ -29,7 +29,7 @@ def _maintenance_mode_hook():
flask.flash(flask.Markup(message), 'danger')
try:
target_url = flask.url_for(endpoint)
except:
except Exception:
# Non-GET-able endpoint, try referrer or default to home page
target_url = flask.request.referrer or flask.url_for('main.home')
return flask.redirect(target_url)

@ -26,6 +26,9 @@ def login():
return flask.redirect(flask.url_for('account.login'))
username = form.username.data.strip()
if not username.isascii():
flask.flash('Invalid characters in username.', 'danger')
return flask.redirect(flask.url_for('account.login'))
password = form.password.data
user = models.User.by_username(username)
@ -151,7 +154,7 @@ def password_reset(payload=None):
s = get_serializer()
try:
request_timestamp, pw_hash, user_id = s.loads(payload)
except:
except Exception:
return flask.abort(404)
user = models.User.by_id(user_id)

@ -1,57 +1,53 @@
alembic==0.9.2
alembic==1.0.11
appdirs==1.4.3
argon2-cffi==16.3.0
autopep8==1.3.1
argon2-cffi==19.1.0
autopep8==1.4.4
blinker==1.4
cffi==1.10.0
click==6.7
dominate==2.3.1
dnspython==1.15.0
elasticsearch==5.3.0
elasticsearch-dsl==5.2.0
flake8==3.3.0
flake8-isort==2.2.1
Flask==0.12.2
cffi==1.12.3
click==7.0
dnspython==1.16.0
elasticsearch==7.0.2
elasticsearch-dsl==7.0.0
flake8==3.7.8
flake8-isort==2.7.0
Flask==1.1.1
Flask-Assets==0.12
Flask-DebugToolbar==0.10.1
Flask-Migrate==2.0.3
flask-paginate==0.4.5
Flask-Script==2.0.5
Flask-SQLAlchemy==2.2
Flask-Migrate==2.5.2
flask-paginate==0.5.3
Flask-Script==2.0.6
Flask-SQLAlchemy==2.4.0
Flask-WTF==0.14.2
gevent==1.3.7
gevent==1.4.0
greenlet==0.4.15
isort==4.2.15
itsdangerous==0.24
Jinja2==2.9.6
libsass==0.12.3
Mako==1.0.6
MarkupSafe==1.0
mysql-replication==0.13
mysqlclient==1.3.10
isort==4.3.21
itsdangerous==1.1.0
Jinja2==2.10.1
Mako==1.1.0
MarkupSafe==1.1.1
mysql-replication==0.19
mysqlclient==1.4.3
orderedset==2.0.1
packaging==16.8
packaging==19.1
passlib==1.7.1
progressbar33==2.4
py==1.4.34
pycodestyle==2.3.1
pycparser==2.17
PyMySQL==0.7.11
pyparsing==2.2.0
pytest==3.1.1
python-dateutil==2.6.0
python-editor==1.0.3
python-utils==2.1.0
requests==2.18.4
six==1.10.0
SQLAlchemy==1.1.10
SQLAlchemy-FullText-Search==0.2.3
SQLAlchemy-Utils==0.32.14
statsd==3.2.1
urllib3==1.21.1
uWSGI==2.0.15
visitor==0.1.3
py==1.8.0
pycodestyle==2.5.0
pycparser==2.19
PyMySQL==0.9.3
pyparsing==2.4.2
pytest==5.0.1
python-dateutil==2.8.0
python-editor==1.0.4
python-utils==2.3.0
requests==2.22.0
SQLAlchemy==1.3.6
SQLAlchemy-FullText-Search==0.2.5
SQLAlchemy-Utils==0.34.1
statsd==3.3.0
urllib3==1.25.3
uWSGI==2.0.18
webassets==0.12.1
Werkzeug==0.12.2
WTForms==2.1
Flask-Caching==1.4.0
Werkzeug==0.15.5
WTForms==2.2.1
Flask-Caching==1.7.2

Loading…
Cancel
Save