Skip to content

Commit 5dd3a49

Browse files
committed
Merge branch 'release/2.7.0'
2 parents 2ebe597 + 09848a9 commit 5dd3a49

File tree

6 files changed

+59
-26
lines changed

6 files changed

+59
-26
lines changed

.github/workflows/main.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: tox
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
timeout-minutes: 2
12+
strategy:
13+
matrix:
14+
python-version: [2.7, 3.6, 3.7, 3.8, 3.9, '3.10']
15+
16+
steps:
17+
- uses: actions/checkout@v2
18+
- name: Set up Python ${{ matrix.python-version }}
19+
uses: actions/setup-python@v2
20+
with:
21+
python-version: ${{ matrix.python-version }}
22+
- name: Install dependencies
23+
run: |
24+
python -m pip install --upgrade pip
25+
pip install tox tox-gh-actions
26+
- name: Test with tox
27+
run: tox

python_utils/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
__package_name__ = 'python-utils'
2-
__version__ = '2.6.3'
2+
__version__ = '2.7.0'
33
__author__ = 'Rick van Hattem'
44
__author_email__ = '[email protected]'
55
__description__ = (

python_utils/converters.py

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
from __future__ import (absolute_import, division, print_function,
2-
unicode_literals)
1+
from __future__ import absolute_import
2+
from __future__ import division
3+
from __future__ import print_function
4+
from __future__ import unicode_literals
35

6+
import decimal
7+
import math
48
import re
9+
510
import six
6-
import math
7-
import decimal
811

912

1013
def to_int(input_, default=0, exception=(ValueError, TypeError), regexp=None):
@@ -263,22 +266,23 @@ def remap(value, old_min, old_max, new_min, new_max):
263266
>>> 0.1 + 0.1 + 0.1
264267
0.30000000000000004
265268
266-
If floating point remaps need to be done my suggstion is to pass at least one
267-
parameter as a `decimal.Decimal`. This will ensure that the output from this
268-
function is accurate. I left passing `floats` for backwards compatability and
269-
there is no conversion done from float to `decimal.Decimal` unless one of the passed
270-
parameters has a type of `decimal.Decimal`. This will ensure that any existing code
271-
that uses this funtion will work exactly how it has in the past.
269+
If floating point remaps need to be done my suggstion is to pass at least
270+
one parameter as a `decimal.Decimal`. This will ensure that the output
271+
from this function is accurate. I left passing `floats` for backwards
272+
compatability and there is no conversion done from float to
273+
`decimal.Decimal` unless one of the passed parameters has a type of
274+
`decimal.Decimal`. This will ensure that any existing code that uses this
275+
funtion will work exactly how it has in the past.
272276
273277
Some edge cases to test
274278
>>> remap(1, 0, 0, 1, 2)
275279
Traceback (most recent call last):
276-
...
280+
...
277281
ValueError: Input range (0-0) is empty
278282
279283
>>> remap(1, 1, 2, 0, 0)
280284
Traceback (most recent call last):
281-
...
285+
...
282286
ValueError: Output range (0-0) is empty
283287
284288
:param value: value to be converted
@@ -310,19 +314,19 @@ def remap(value, old_min, old_max, new_min, new_max):
310314
'''
311315

312316
if (
313-
isinstance(value, decimal.Decimal) or
314-
isinstance(old_min, decimal.Decimal) or
315-
isinstance(old_max, decimal.Decimal) or
316-
isinstance(new_min, decimal.Decimal) or
317-
isinstance(new_max, decimal.Decimal)
317+
isinstance(value, decimal.Decimal) or
318+
isinstance(old_min, decimal.Decimal) or
319+
isinstance(old_max, decimal.Decimal) or
320+
isinstance(new_min, decimal.Decimal) or
321+
isinstance(new_max, decimal.Decimal)
318322
):
319323
type_ = decimal.Decimal
320324
elif (
321-
isinstance(value, float) or
322-
isinstance(old_min, float) or
323-
isinstance(old_max, float) or
324-
isinstance(new_min, float) or
325-
isinstance(new_max, float)
325+
isinstance(value, float) or
326+
isinstance(old_min, float) or
327+
isinstance(old_max, float) or
328+
isinstance(new_min, float) or
329+
isinstance(new_max, float)
326330
):
327331
type_ = float
328332

python_utils/time.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def timeout_generator(
163163

164164
if six.PY3: # pragma: no cover
165165
timer = time.perf_counter
166-
else:
166+
else: # pragma: no cover
167167
timer = time.time
168168

169169
end = timeout + timer()

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
tests_require=['pytest'],
3636
extras_require={
3737
'docs': [
38+
'six',
3839
'mock',
3940
'sphinx',
4041
'python-utils',

tox.ini

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = py27, py35, py36, py37, py38, py39, pypy, flake8, docs
2+
envlist = py27, py35, py36, py37, py38, py39, py310, pypy, flake8, docs
33
skip_missing_interpreters = True
44

55
[testenv]
@@ -10,6 +10,7 @@ basepython =
1010
py37: python3.7
1111
py38: python3.8
1212
py39: python3.9
13+
py310: python3.10
1314
pypy: pypy
1415

1516
setenv = PY_IGNORE_IMPORTMISMATCH=1
@@ -19,7 +20,7 @@ commands = py.test --basetemp="{envtmpdir}" --confcutdir=.. {posargs} python_uti
1920
[testenv:flake8]
2021
basepython = python3
2122
deps = flake8
22-
commands = flake8 --ignore=W391 python_utils {posargs}
23+
commands = flake8 python_utils {posargs}
2324

2425
[testenv:docs]
2526
basepython = python3

0 commit comments

Comments
 (0)