Skip to content

Commit a6a4645

Browse files
committed
BREAK: remove 2.7 support; remove docker; use travis python
1 parent 40fff2d commit a6a4645

15 files changed

+144
-145
lines changed

.travis.yml

+48-17
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,50 @@
11
language: python
2-
sudo: required
3-
services:
4-
- docker
5-
script:
6-
- make docker/build
7-
before_install:
8-
- pip install codecov
2+
python:
3+
- "3.6"
4+
- "3.7"
5+
- "3.8"
6+
install:
7+
- pip install codecov tox-travis
8+
script: tox
99
after_success:
10-
- codecov
11-
deploy:
12-
provider: pypi
13-
user: kpn-digital
14-
skip_cleanup: true
15-
password:
16-
secure: U4xdw255nzxtgjDb1IDROodBYp19RtTfsSkn3SX87s04/FF3/6jx46NQWLdnorZyCNkpTueKCWpUo364IeXtzg5XxyDNmOZUOkZYbzsszb7ZrCfC+4/mQiY1xl9ZDjDdnjgS2TPw1Zik2SVbwD3duwkXah9Juh8MkpcqYwFNSVjjUXVDiY7qN6VLT/uTqVDK6oTLKDZqMhMMSQ3tlVkdxGuR3CrXUOxreEiBod2WxCjprgZpzNBK9S0SNRNI/K8WtRUye7FMAGpkqR2+aQrFQre3qaALoYDSod+0Xknrsa0Bfz2RaCf0Mu6CBhKADMAc+1015r1w6MZ44T0YI223JMI81XTPcilpwnxDAQ+/+xM6vPIeMWtPEd0973WTPNdTMIZSgS1O45h7wwfUImf/t9nvCgbBliEFkPDOm5HsOc1YWu6LiagH5FbUwU5HCYlaXshwu2fPLwrlR3TvYa7ptPbiPiJ4BCHMWkHklXjzWcPR4vf86asaLe5jwq7A/nD9Kex514p/tzlBKotpddu6PSS7FxO5tfOVW5fxayS8RzmXdnsYFpb96Mlgk6qfGfhJ8EzOEqwrdjRgfuFKjceSWN5Lae5cS8F3n0cA88warvkiYlU9egnzAVCNYPppjMu93PXl361bqTC0yOwkcQfvKdc7TjtNA9D2UovEapuDxb8=
17-
on:
18-
tags: true
19-
all_branches: true
10+
- codecov
11+
12+
stages:
13+
- name: lint checks
14+
- name: test
15+
- name: check build
16+
- name: deploy
17+
18+
jobs:
19+
include:
20+
- stage: lint checks
21+
language: generic
22+
services: docker
23+
install: true
24+
after_success: true
25+
script:
26+
- docker run -v $(pwd):/app -w /app -i -t python:3.7 bash -c "make lint"
27+
before_install:
28+
- docker pull python:3.7
29+
- stage: check build
30+
language: generic
31+
services: docker
32+
install: true
33+
after_success: true
34+
script:
35+
- docker run -v $(pwd):/app -w /app -i -t python:3.7 bash -c "make build"
36+
before_install:
37+
- docker pull python:3.7
38+
- stage: deploy
39+
script: skip
40+
install: true
41+
after_success: true
42+
deploy:
43+
provider: pypi
44+
user: kpn-digital
45+
skip_cleanup: true
46+
password:
47+
secure: U4xdw255nzxtgjDb1IDROodBYp19RtTfsSkn3SX87s04/FF3 /6jx46NQWLdnorZyCNkpTueKCWpUo364IeXtzg5XxyDNmOZUOkZYbzsszb7ZrCfC+4 /mQiY1xl9ZDjDdnjgS2TPw1Zik2SVbwD3duwkXah9Juh8MkpcqYwFNSVjjUXVDiY7qN6VLT /uTqVDK6oTLKDZqMhMMSQ3tlVkdxGuR3CrXUOxreEiBod2WxCjprgZpzNBK9S0SNRNI/K8WtRUye7FMAGpkqR2+aQrFQre3qaALoYDSod+0Xknrsa0Bfz2RaCf0Mu6CBhKADMAc+1015r1w6MZ44T0YI223JMI81XTPcilpwnxDAQ+/+xM6vPIeMWtPEd0973WTPNdTMIZSgS1O45h7wwfUImf/t9nvCgbBliEFkPDOm5HsOc1YWu6LiagH5FbUwU5HCYlaXshwu2fPLwrlR3TvYa7ptPbiPiJ4BCHMWkHklXjzWcPR4vf86asaLe5jwq7A/nD9Kex514p/tzlBKotpddu6PSS7FxO5tfOVW5fxayS8RzmXdnsYFpb96Mlgk6qfGfhJ8EzOEqwrdjRgfuFKjceSWN5Lae5cS8F3n0cA88warvkiYlU9egnzAVCNYPppjMu93PXl361bqTC0yOwkcQfvKdc7TjtNA9D2UovEapuDxb8=
48+
on:
49+
tags: true
50+
all_branches: true

Dockerfile

-5
This file was deleted.

Makefile

+53-45
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,70 @@
11
# This Makefile requires the following commands to be available:
2-
# * python3.6
3-
# * docker
4-
# * docker-compose
2+
# * python3.7
53

6-
DEPS:=requirements.txt
7-
DOCKER_COMPOSE:=$(shell which docker-compose)
8-
9-
PIP:="venv/bin/pip"
10-
CMD_FROM_VENV:=". venv/bin/activate; which"
11-
TOX=$(shell "$(CMD_FROM_VENV)" "tox")
12-
PYTHON=$(shell "$(CMD_FROM_VENV)" "python")
13-
TWINE=$(shell "$(CMD_FROM_VENV)" "twine")
14-
TOX_PY_LIST="$(shell $(TOX) -l | grep ^py | xargs | sed -e 's/ /,/g')"
15-
16-
.PHONY: clean pyclean test lint isort docker setup.py build publish
17-
18-
tox:
19-
$(TOX)
4+
SRC:=fqn_decorators tests setup.py
205

6+
.PHONY: pyclean
217
pyclean:
22-
@find . -name *.pyc -delete
23-
@rm -rf *.egg-info build
24-
@rm -rf coverage.xml .coverage
8+
-find . -name "*.pyc" -delete
9+
-rm -rf *.egg-info build
10+
-rm -rf coverage*.xml .coverage
2511

12+
.PHONY: clean
2613
clean: pyclean
27-
@rm -rf venv
28-
@rm -rf .tox
14+
-rm -rf venv
15+
-rm -rf .tox
2916

17+
venv: PYTHON?=python3.7
3018
venv:
31-
@python3.6 -m venv venv
32-
@$(PIP) install -U "pip>=7.0" -q
33-
@$(PIP) install -U setuptools -q
34-
@$(PIP) install --use-feature=2020-resolver -r $(DEPS)
19+
$(PYTHON) -m venv venv
20+
venv/bin/pip install -U "pip>=7.0" -q
21+
venv/bin/pip install -U setuptools -q
22+
venv/bin/pip install -r requirements.txt
23+
24+
## Code style
25+
.PHONY: lint
26+
lint: lint/black lint/flake8 lint/isort lint/mypy
3527

36-
test: venv pyclean
37-
$(TOX) -e $(TOX_PY_LIST)
28+
.PHONY: lint/black
29+
lint/black: venv
30+
venv/bin/black --diff --check $(SRC)
3831

39-
test/%: venv pyclean
40-
$(TOX) -e $(TOX_PY_LIST) -- $*
32+
.PHONY: lint/flake8
33+
lint/flake8: venv
34+
venv/bin/flake8 $(SRC)
4135

42-
lint: venv
43-
@$(TOX) -e isort-check
44-
@$(TOX) -e flake8
36+
.PHONY: lint/isort
37+
lint/isort: venv
38+
venv/bin/isort --diff --check $(SRC)
4539

46-
isort: venv
47-
@$(TOX) -e isort-fix
40+
.PHONY: lint/mypy
41+
lint/mypy: venv
42+
venv/bin/mypy $(SRC)
4843

49-
docker:
50-
$(DOCKER_COMPOSE) run --rm --service-ports app bash
44+
.PHONY: format
45+
format: format/isort format/black
5146

52-
docker/%:
53-
$(DOCKER_COMPOSE) run --rm --service-ports app make $*
47+
.PHONY: format/isort
48+
format/isort: venv
49+
venv/bin/isort $(SRC)
50+
51+
.PHONY: format/black
52+
format/black: venv
53+
venv/bin/black $(SRC)
54+
55+
## Tests
56+
.PHONY: unittests
57+
unittests: TOX_ENV?=ALL
58+
unittests: TOX_EXTRA_PARAMS?=""
59+
unittests: venv
60+
venv/bin/tox -e $(TOX_ENV) $(TOX_EXTRA_PARAMS)
61+
62+
.PHONY: test
63+
test: pyclean venv unittests
5464

5565
## Distribution
56-
build: venv tox
66+
.PHONY: build
67+
build: venv
5768
-rm -rf dist build
58-
$(PYTHON) setup.py sdist bdist_wheel
59-
$(TWINE) check dist/*
60-
61-
publish: build
62-
$(TWINE) upload dist/*
69+
venv/bin/python setup.py sdist bdist_wheel
70+
venv/bin/twine check dist/*

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,13 @@ Async Decorator
9696
There's also support for decorating coroutines (or any awaitable), for Python >=3.5 only.
9797

9898
The implementation is the same as with the sync version, just inherit from
99-
`fqn_decorators.async.AsyncDecorator` instead.
99+
`fqn_decorators.asynchronous.AsyncDecorator` instead.
100100

101101
Example:
102102
```python
103103
import asyncio
104104
import time
105-
from fqn_decorators.async import AsyncDecorator
105+
from fqn_decorators.asynchronous import AsyncDecorator
106106

107107
class time_it_async(AsyncDecorator):
108108

docker-compose.yml

-5
This file was deleted.

fqn_decorators/__init__.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
# -*- coding: utf-8 -*-
2-
from .decorators import *
1+
from .decorators import * # noqa: F403, F401

fqn_decorators/decorators.py

+13-20
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
import functools
32
import sys
43

@@ -9,29 +8,23 @@ def get_fqn(obj):
98
It only works for classes, methods and functions.
109
It is unable to properly determine the FQN of class instances, static methods and class methods.
1110
"""
12-
path = [getattr(obj, "__module__", None)]
13-
qualname = getattr(obj, "__qualname__", None)
14-
if qualname:
15-
path.append(qualname.replace("<locals>.", ""))
16-
im_self = getattr(obj, "__self__", None)
17-
im_class = getattr(im_self, "__class__", None)
18-
if im_self and im_class:
19-
path = [
20-
getattr(im_class, "__module__", None),
21-
getattr(im_class, "__name__", None),
22-
getattr(obj, "__name__", None),
23-
]
11+
im_self = getattr(obj, "__self__", None)
12+
im_class = getattr(im_self, "__class__", None)
13+
if im_self and im_class:
14+
path = [
15+
getattr(im_class, "__module__", None),
16+
getattr(im_class, "__name__", None),
17+
getattr(obj, "__name__", None),
18+
]
2419
else:
25-
im_class = getattr(obj, "im_class", None)
26-
im_class_module = getattr(im_class, "__module__", None)
27-
if im_class and im_class_module:
28-
path = [im_class_module]
29-
path.append(getattr(im_class, "__name__", None))
30-
path.append(getattr(obj, "__name__", None))
20+
path = [
21+
getattr(obj, "__module__", None),
22+
getattr(obj, "__qualname__", "").replace("<locals>.", ""),
23+
]
3124
return ".".join(filter(None, path))
3225

3326

34-
class Decorator(object):
27+
class Decorator:
3528
"""
3629
A base class to easily create decorators.
3730
"""

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.black]
22
line-length = 120
3-
target_version = ["py27", "py35", "py36", "py37"]
3+
target_version = ["py36", "py37", "py38"]
44

55
[tool.isort]
66
combine_as_imports = true

requirements.txt

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
# Package in develop mode
22
-e .
33

4-
importlib-metadata
4+
# Latest tox (3.20.1 at the moment) requires importlib-metadata<3,>=0.12
5+
importlib-metadata<3
56

67
# Distribution
78
twine
89
wheel
910

1011
# Code style
11-
mypy; python_version >= '3.5'
12+
mypy
1213
isort[pyproject]
1314
flake8
15+
black
1416

1517
# Tests
16-
tox
18+
tox==3.20.1
1719
pytest
1820
pytest-cov
1921
pytest-asyncio; python_version >= '3.5'

setup.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#!/usr/bin/env python
2-
# -*- coding: utf-8 -*-
3-
from setuptools import find_packages, setup
2+
3+
# setuptools doesn't support type hints for now:
4+
# https://github.com/pypa/setuptools/issues/2345
5+
# so we ignoring mypy checks on this package
6+
from setuptools import find_packages, setup # type: ignore
47

58
with open("README.md") as f:
69
long_description = f.read()
@@ -26,10 +29,7 @@
2629
"Intended Audience :: Developers",
2730
"Operating System :: OS Independent",
2831
"Programming Language :: Python",
29-
"Programming Language :: Python :: 2",
30-
"Programming Language :: Python :: 2.7",
3132
"Programming Language :: Python :: 3",
32-
"Programming Language :: Python :: 3.5",
3333
"Programming Language :: Python :: 3.6",
3434
"Programming Language :: Python :: 3.7",
3535
"Programming Language :: Python :: 3.8",

tests/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
# -*- coding: utf-8 -*-

tests/conftest.py

-2
This file was deleted.

tests/examples.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ def my_test_func(a):
77

88

99
@fqn_decorators.Decorator()
10-
class A(object):
10+
class A:
1111
@fqn_decorators.Decorator
1212
def method(self, a):
1313
return a
1414

1515

16-
class B(object):
16+
class B:
1717
@fqn_decorators.Decorator
1818
def method(self, b):
1919
return b

0 commit comments

Comments
 (0)