diff --git a/.drone.yml b/.drone.yml index e0bc2f7026..5da6083eb7 100644 --- a/.drone.yml +++ b/.drone.yml @@ -25,12 +25,6 @@ services: matrix: include: - - IMAGE: python:2.7 - TOXENV: py27 - DATABASE: sqlite - - IMAGE: python:2.7 - TOXENV: py27 - DATABASE: postgresql - IMAGE: python:3.4 TOXENV: py34 DATABASE: sqlite diff --git a/CHANGELOG b/CHANGELOG index 2b76346966..38d3d53f1f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +* Remove support for Python 2.7 + Version 4.8.0 - 2018-04-23 * Bug fixes (see mercurial logs for details) * Make description on purchase request optional diff --git a/INSTALL b/INSTALL index a7ddb7d1f9..ee85f7e3d1 100644 --- a/INSTALL +++ b/INSTALL @@ -4,7 +4,7 @@ Installing trytond_purchase_request Prerequisites ------------- - * Python 2.7 or later (http://www.python.org/) + * Python 3.4 or later (http://www.python.org/) * trytond (http://www.tryton.org/) Installation diff --git a/party.py b/party.py index 7e658d0e27..0cf3b9a87d 100644 --- a/party.py +++ b/party.py @@ -5,8 +5,7 @@ from trytond.pool import PoolMeta __all__ = ['PartyReplace'] -class PartyReplace: - __metaclass__ = PoolMeta +class PartyReplace(metaclass=PoolMeta): __name__ = 'party.replace' @classmethod diff --git a/purchase.py b/purchase.py index 9ffc12f8b1..5d186a9db7 100644 --- a/purchase.py +++ b/purchase.py @@ -21,9 +21,8 @@ def process_request(func): return wrapper -class Purchase: +class Purchase(metaclass=PoolMeta): __name__ = 'purchase.purchase' - __metaclass__ = PoolMeta @classmethod def __setup__(cls): @@ -89,8 +88,7 @@ class Purchase: super(Purchase, cls).do(purchases) -class PurchaseLine: - __metaclass__ = PoolMeta +class PurchaseLine(metaclass=PoolMeta): __name__ = 'purchase.line' requests = fields.One2Many( diff --git a/purchase_request.py b/purchase_request.py index 30d3baba11..9f1fdfaadc 100644 --- a/purchase_request.py +++ b/purchase_request.py @@ -2,7 +2,7 @@ # this repository contains the full copyright notices and license terms. import datetime from decimal import Decimal -from itertools import groupby, ifilter +from itertools import groupby from functools import partial from trytond import backend @@ -384,7 +384,7 @@ class CreatePurchase(Wizard): and request.product == self.ask_party.product and compare_string( request.description, self.ask_party.description)) - reqs = filter(to_write, requests) + reqs = list(filter(to_write, requests)) if reqs: Request.write(reqs, { 'party': self.ask_party.party.id, @@ -396,7 +396,7 @@ class CreatePurchase(Wizard): def to_ask_party(request): return not request.purchase_line and not request.party - reqs = ifilter(to_ask_party, requests) + reqs = filter(to_ask_party, requests) if any(reqs): return 'ask_party' diff --git a/setup.py b/setup.py index bc0c8a5ae4..4f441f92a0 100644 --- a/setup.py +++ b/setup.py @@ -1,15 +1,12 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # This file is part of Tryton. The COPYRIGHT file at the top level of # this repository contains the full copyright notices and license terms. -from setuptools import setup -import re -import os import io -try: - from configparser import ConfigParser -except ImportError: - from ConfigParser import ConfigParser +import os +import re +from configparser import ConfigParser +from setuptools import setup def read(fname): @@ -27,6 +24,7 @@ def get_require_version(name): major_version, minor_version + 1) return require + config = ConfigParser() config.readfp(open('tryton.cfg')) info = dict(config.items('tryton')) @@ -103,7 +101,6 @@ setup(name=name, 'Natural Language :: Slovenian', 'Natural Language :: Spanish', 'Operating System :: OS Independent', - 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', @@ -112,6 +109,7 @@ setup(name=name, 'Topic :: Office/Business', ], license='GPL-3', + python_requires='>=3.4', install_requires=requires, dependency_links=dependency_links, zip_safe=False, @@ -121,9 +119,5 @@ setup(name=name, """, test_suite='tests', test_loader='trytond.test_loader:Loader', - use_2to3=True, - convert_2to3_doctests=[ - 'tests/scenario_purchase_request.rst', - ], tests_require=tests_require, ) diff --git a/tests/scenario_purchase_request.rst b/tests/scenario_purchase_request.rst index a0367f7e4f..891ccc84ec 100644 --- a/tests/scenario_purchase_request.rst +++ b/tests/scenario_purchase_request.rst @@ -169,14 +169,14 @@ Create the purchase then cancel it:: >>> create_purchase.form.party = supplier >>> create_purchase.execute('start') >>> pr.state - u'purchased' + 'purchased' >>> Purchase = Model.get('purchase.purchase') >>> purchase, = Purchase.find() >>> purchase.click('cancel') >>> pr.reload() >>> pr.state - u'exception' + 'exception' Handle the exception:: @@ -184,20 +184,20 @@ Handle the exception:: ... 'purchase.request.handle.purchase.cancellation', [pr]) >>> handle_exception.execute('reset') >>> pr.state - u'draft' + 'draft' Recreate a purchase and cancel it again:: >>> create_purchase = Wizard('purchase.request.create_purchase', ... [pr]) >>> pr.state - u'purchased' + 'purchased' >>> purchase, = Purchase.find([('state', '=', 'draft')]) >>> purchase.click('cancel') >>> pr.reload() >>> pr.state - u'exception' + 'exception' Handle again the exception:: @@ -205,7 +205,7 @@ Handle again the exception:: ... 'purchase.request.handle.purchase.cancellation', [pr]) >>> handle_exception.execute('cancel_request') >>> pr.state - u'cancel' + 'cancel' Re-create the purchase request:: @@ -236,7 +236,7 @@ Create the purchase with a unique line:: >>> create_purchase.form.party = supplier >>> create_purchase.execute('start') >>> pr.state - u'purchased' + 'purchased' >>> Purchase = Model.get('purchase.purchase') >>> purchase, = Purchase.find([('state', '=', 'draft')]) @@ -265,11 +265,11 @@ Create the purchase without product:: >>> create_purchase.form.party = supplier >>> create_purchase.execute('start') >>> pr.state - u'purchased' + 'purchased' >>> pr.purchase_line.product >>> pr.purchase_line.description - u'Custom product' + 'Custom product' >>> pr.purchase_line.quantity 1.0 >>> pr.purchase_line.unit diff --git a/tox.ini b/tox.ini index 2082ab4f4d..adbcbf8431 100644 --- a/tox.ini +++ b/tox.ini @@ -1,11 +1,11 @@ [tox] -envlist = {py27,py34,py35,py36}-{sqlite,postgresql},pypy-{sqlite,postgresql} +envlist = {py34,py35,py36}-{sqlite,postgresql},pypy3-{sqlite,postgresql} [testenv] commands = {envpython} setup.py test deps = - {py27,py34,py35,py36}-postgresql: psycopg2 >= 2.5 - pypy-postgresql: psycopg2cffi >= 2.5 + {py34,py35,py36}-postgresql: psycopg2 >= 2.5 + pypy3-postgresql: psycopg2cffi >= 2.5 sqlite: sqlitebck setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://}