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 eb5cdeb039..9d5dbe858f 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) diff --git a/INSTALL b/INSTALL index 89f4fdee7d..44832dfd01 100644 --- a/INSTALL +++ b/INSTALL @@ -4,7 +4,7 @@ Installing trytond_purchase_shipment_cost Prerequisites ------------- - * Python 2.7 or later (http://www.python.org/) + * Python 3.4 or later (http://www.python.org/) * trytond (http://www.tryton.org/) * trytond_carrier (http://www.tryton.org/) * trytond_currency (http://www.tryton.org/) diff --git a/__init__.py b/__init__.py index 26948176c2..36b119010f 100644 --- a/__init__.py +++ b/__init__.py @@ -2,13 +2,13 @@ # this repository contains the full copyright notices and license terms. from trytond.pool import Pool -from stock import * -from carrier import * +from . import stock +from . import carrier def register(): Pool.register( - ShipmentIn, - Move, - Carrier, + stock.ShipmentIn, + stock.Move, + carrier.Carrier, module='purchase_shipment_cost', type_='model') diff --git a/carrier.py b/carrier.py index d0209230b3..037e783161 100644 --- a/carrier.py +++ b/carrier.py @@ -6,8 +6,7 @@ from trytond.pool import PoolMeta __all__ = ['Carrier'] -class Carrier: - __metaclass__ = PoolMeta +class Carrier(metaclass=PoolMeta): __name__ = 'carrier' carrier_cost_allocation_method = fields.Selection([ ('value', 'By Value'), diff --git a/setup.py b/setup.py index 6bfafc445f..c0c7354f36 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')) @@ -59,7 +57,6 @@ for dep in info.get('extras_depend', []): extras_require[dep] = get_require_version('trytond_%s' % dep) tests_require = [get_require_version('proteus'), - 'mock', # For account_stock_anglo_saxon tests tools get_require_version('trytond_account_stock_continental'), get_require_version('trytond_account_stock_anglo_saxon'), get_require_version('trytond_purchase')] @@ -111,7 +108,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', @@ -120,6 +116,7 @@ setup(name=name, 'Topic :: Office/Business', ], license='GPL-3', + python_requires='>=3.4', install_requires=requires, extras_require=extras_require, dependency_links=dependency_links, @@ -131,10 +128,4 @@ setup(name=name, test_suite='tests', test_loader='trytond.test_loader:Loader', tests_require=tests_require, - use_2to3=True, - convert_2to3_doctests=[ - 'tests/scenario_purchase_shipment_cost.rst', - 'tests/scenario_purchase_shipment_cost_with_account_stock.rst', - 'tests/scenario_purchase_shipment_cost_with_account_stock_anglo_saxon.rst', - ], ) diff --git a/stock.py b/stock.py index 8e4956057e..5a8f73d2a6 100644 --- a/stock.py +++ b/stock.py @@ -13,8 +13,7 @@ from trytond.modules.product import price_digits __all__ = ['ShipmentIn', 'Move'] -class ShipmentIn: - __metaclass__ = PoolMeta +class ShipmentIn(metaclass=PoolMeta): __name__ = 'stock.shipment.in' carrier = fields.Many2One('carrier', 'Carrier', states={ 'readonly': Eval('state') != 'draft', @@ -139,8 +138,7 @@ class ShipmentIn: super(ShipmentIn, cls).receive(shipments) -class Move: - __metaclass__ = PoolMeta +class Move(metaclass=PoolMeta): __name__ = 'stock.move' unit_shipment_cost = fields.Numeric('Unit Shipment Cost', digits=price_digits, readonly=True) diff --git a/tests/scenario_purchase_shipment_cost.rst b/tests/scenario_purchase_shipment_cost.rst index 14b9e03bef..13da553595 100644 --- a/tests/scenario_purchase_shipment_cost.rst +++ b/tests/scenario_purchase_shipment_cost.rst @@ -89,7 +89,7 @@ Receive a single product line:: True >>> shipment.click('receive') >>> shipment.state - u'received' + 'received' >>> move, = shipment.incoming_moves >>> move.unit_price Decimal('8.0600') @@ -110,7 +110,7 @@ Receive many product lines:: Decimal('3') >>> shipment.click('receive') >>> shipment.state - u'received' + 'received' >>> [move.unit_price for move in shipment.incoming_moves] == \ ... [Decimal('8.3333'), Decimal('8.3333'), Decimal('8.3334')] True @@ -136,6 +136,6 @@ Receive a two lines with no cost:: Decimal('3') >>> shipment.click('receive') >>> shipment.state - u'received' + 'received' >>> tuple(m.unit_price for m in shipment.incoming_moves) (Decimal('0.0600'), Decimal('0.0200')) diff --git a/tests/scenario_purchase_shipment_cost_with_account_stock.rst b/tests/scenario_purchase_shipment_cost_with_account_stock.rst index ee83937863..a55bbbf36b 100644 --- a/tests/scenario_purchase_shipment_cost_with_account_stock.rst +++ b/tests/scenario_purchase_shipment_cost_with_account_stock.rst @@ -148,7 +148,7 @@ Receive a single product line:: True >>> shipment.click('receive') >>> shipment.state - u'received' + 'received' >>> move, move_average = shipment.incoming_moves >>> move.unit_price Decimal('8.0600') @@ -183,7 +183,7 @@ Receive many product lines:: Decimal('3') >>> shipment.click('receive') >>> shipment.state - u'received' + 'received' >>> [move.unit_price for move in shipment.incoming_moves] == \ ... [Decimal('8.3333'), Decimal('8.3333'), Decimal('8.3334')] True diff --git a/tests/scenario_purchase_shipment_cost_with_account_stock_anglo_saxon.rst b/tests/scenario_purchase_shipment_cost_with_account_stock_anglo_saxon.rst index 50aa89adcb..b9a8a80339 100644 --- a/tests/scenario_purchase_shipment_cost_with_account_stock_anglo_saxon.rst +++ b/tests/scenario_purchase_shipment_cost_with_account_stock_anglo_saxon.rst @@ -142,7 +142,7 @@ Purchase 5 products:: >>> purchase.click('confirm') >>> purchase.click('process') >>> purchase.state - u'processing' + 'processing' Receive 4 products:: @@ -159,13 +159,13 @@ Receive 4 products:: True >>> shipment.click('receive') >>> shipment.state - u'received' + 'received' >>> move, = shipment.incoming_moves >>> move.unit_price Decimal('5.7500') >>> shipment.click('done') >>> shipment.state - u'done' + 'done' >>> stock_supplier.reload() >>> stock.reload() >>> stock_supplier.debit @@ -192,7 +192,7 @@ Open supplier invoice:: >>> invoice.save() >>> invoice.click('post') >>> invoice.state - u'posted' + 'posted' >>> payable.reload() >>> payable.debit Decimal('0.00') 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://}