Skip to content

Commit

Permalink
Merge pull request #19 from aikikode/feature/drop_27_support
Browse files Browse the repository at this point in the history
BREAK: remove 2.7 support; remove docker; use travis python
  • Loading branch information
kammala authored Dec 1, 2020
2 parents 40fff2d + a6a4645 commit 7e9541a
Show file tree
Hide file tree
Showing 15 changed files with 144 additions and 145 deletions.
65 changes: 48 additions & 17 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,50 @@
language: python
sudo: required
services:
- docker
script:
- make docker/build
before_install:
- pip install codecov
python:
- "3.6"
- "3.7"
- "3.8"
install:
- pip install codecov tox-travis
script: tox
after_success:
- codecov
deploy:
provider: pypi
user: kpn-digital
skip_cleanup: true
password:
secure: U4xdw255nzxtgjDb1IDROodBYp19RtTfsSkn3SX87s04/FF3/6jx46NQWLdnorZyCNkpTueKCWpUo364IeXtzg5XxyDNmOZUOkZYbzsszb7ZrCfC+4/mQiY1xl9ZDjDdnjgS2TPw1Zik2SVbwD3duwkXah9Juh8MkpcqYwFNSVjjUXVDiY7qN6VLT/uTqVDK6oTLKDZqMhMMSQ3tlVkdxGuR3CrXUOxreEiBod2WxCjprgZpzNBK9S0SNRNI/K8WtRUye7FMAGpkqR2+aQrFQre3qaALoYDSod+0Xknrsa0Bfz2RaCf0Mu6CBhKADMAc+1015r1w6MZ44T0YI223JMI81XTPcilpwnxDAQ+/+xM6vPIeMWtPEd0973WTPNdTMIZSgS1O45h7wwfUImf/t9nvCgbBliEFkPDOm5HsOc1YWu6LiagH5FbUwU5HCYlaXshwu2fPLwrlR3TvYa7ptPbiPiJ4BCHMWkHklXjzWcPR4vf86asaLe5jwq7A/nD9Kex514p/tzlBKotpddu6PSS7FxO5tfOVW5fxayS8RzmXdnsYFpb96Mlgk6qfGfhJ8EzOEqwrdjRgfuFKjceSWN5Lae5cS8F3n0cA88warvkiYlU9egnzAVCNYPppjMu93PXl361bqTC0yOwkcQfvKdc7TjtNA9D2UovEapuDxb8=
on:
tags: true
all_branches: true
- codecov

stages:
- name: lint checks
- name: test
- name: check build
- name: deploy

jobs:
include:
- stage: lint checks
language: generic
services: docker
install: true
after_success: true
script:
- docker run -v $(pwd):/app -w /app -i -t python:3.7 bash -c "make lint"
before_install:
- docker pull python:3.7
- stage: check build
language: generic
services: docker
install: true
after_success: true
script:
- docker run -v $(pwd):/app -w /app -i -t python:3.7 bash -c "make build"
before_install:
- docker pull python:3.7
- stage: deploy
script: skip
install: true
after_success: true
deploy:
provider: pypi
user: kpn-digital
skip_cleanup: true
password:
secure: U4xdw255nzxtgjDb1IDROodBYp19RtTfsSkn3SX87s04/FF3 /6jx46NQWLdnorZyCNkpTueKCWpUo364IeXtzg5XxyDNmOZUOkZYbzsszb7ZrCfC+4 /mQiY1xl9ZDjDdnjgS2TPw1Zik2SVbwD3duwkXah9Juh8MkpcqYwFNSVjjUXVDiY7qN6VLT /uTqVDK6oTLKDZqMhMMSQ3tlVkdxGuR3CrXUOxreEiBod2WxCjprgZpzNBK9S0SNRNI/K8WtRUye7FMAGpkqR2+aQrFQre3qaALoYDSod+0Xknrsa0Bfz2RaCf0Mu6CBhKADMAc+1015r1w6MZ44T0YI223JMI81XTPcilpwnxDAQ+/+xM6vPIeMWtPEd0973WTPNdTMIZSgS1O45h7wwfUImf/t9nvCgbBliEFkPDOm5HsOc1YWu6LiagH5FbUwU5HCYlaXshwu2fPLwrlR3TvYa7ptPbiPiJ4BCHMWkHklXjzWcPR4vf86asaLe5jwq7A/nD9Kex514p/tzlBKotpddu6PSS7FxO5tfOVW5fxayS8RzmXdnsYFpb96Mlgk6qfGfhJ8EzOEqwrdjRgfuFKjceSWN5Lae5cS8F3n0cA88warvkiYlU9egnzAVCNYPppjMu93PXl361bqTC0yOwkcQfvKdc7TjtNA9D2UovEapuDxb8=
on:
tags: true
all_branches: true
5 changes: 0 additions & 5 deletions Dockerfile

This file was deleted.

98 changes: 53 additions & 45 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,62 +1,70 @@
# This Makefile requires the following commands to be available:
# * python3.6
# * docker
# * docker-compose
# * python3.7

DEPS:=requirements.txt
DOCKER_COMPOSE:=$(shell which docker-compose)

PIP:="venv/bin/pip"
CMD_FROM_VENV:=". venv/bin/activate; which"
TOX=$(shell "$(CMD_FROM_VENV)" "tox")
PYTHON=$(shell "$(CMD_FROM_VENV)" "python")
TWINE=$(shell "$(CMD_FROM_VENV)" "twine")
TOX_PY_LIST="$(shell $(TOX) -l | grep ^py | xargs | sed -e 's/ /,/g')"

.PHONY: clean pyclean test lint isort docker setup.py build publish

tox:
$(TOX)
SRC:=fqn_decorators tests setup.py

.PHONY: pyclean
pyclean:
@find . -name *.pyc -delete
@rm -rf *.egg-info build
@rm -rf coverage.xml .coverage
-find . -name "*.pyc" -delete
-rm -rf *.egg-info build
-rm -rf coverage*.xml .coverage

.PHONY: clean
clean: pyclean
@rm -rf venv
@rm -rf .tox
-rm -rf venv
-rm -rf .tox

venv: PYTHON?=python3.7
venv:
@python3.6 -m venv venv
@$(PIP) install -U "pip>=7.0" -q
@$(PIP) install -U setuptools -q
@$(PIP) install --use-feature=2020-resolver -r $(DEPS)
$(PYTHON) -m venv venv
venv/bin/pip install -U "pip>=7.0" -q
venv/bin/pip install -U setuptools -q
venv/bin/pip install -r requirements.txt

## Code style
.PHONY: lint
lint: lint/black lint/flake8 lint/isort lint/mypy

test: venv pyclean
$(TOX) -e $(TOX_PY_LIST)
.PHONY: lint/black
lint/black: venv
venv/bin/black --diff --check $(SRC)

test/%: venv pyclean
$(TOX) -e $(TOX_PY_LIST) -- $*
.PHONY: lint/flake8
lint/flake8: venv
venv/bin/flake8 $(SRC)

lint: venv
@$(TOX) -e isort-check
@$(TOX) -e flake8
.PHONY: lint/isort
lint/isort: venv
venv/bin/isort --diff --check $(SRC)

isort: venv
@$(TOX) -e isort-fix
.PHONY: lint/mypy
lint/mypy: venv
venv/bin/mypy $(SRC)

docker:
$(DOCKER_COMPOSE) run --rm --service-ports app bash
.PHONY: format
format: format/isort format/black

docker/%:
$(DOCKER_COMPOSE) run --rm --service-ports app make $*
.PHONY: format/isort
format/isort: venv
venv/bin/isort $(SRC)

.PHONY: format/black
format/black: venv
venv/bin/black $(SRC)

## Tests
.PHONY: unittests
unittests: TOX_ENV?=ALL
unittests: TOX_EXTRA_PARAMS?=""
unittests: venv
venv/bin/tox -e $(TOX_ENV) $(TOX_EXTRA_PARAMS)

.PHONY: test
test: pyclean venv unittests

## Distribution
build: venv tox
.PHONY: build
build: venv
-rm -rf dist build
$(PYTHON) setup.py sdist bdist_wheel
$(TWINE) check dist/*

publish: build
$(TWINE) upload dist/*
venv/bin/python setup.py sdist bdist_wheel
venv/bin/twine check dist/*
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,13 @@ Async Decorator
There's also support for decorating coroutines (or any awaitable), for Python >=3.5 only.

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

Example:
```python
import asyncio
import time
from fqn_decorators.async import AsyncDecorator
from fqn_decorators.asynchronous import AsyncDecorator

class time_it_async(AsyncDecorator):

Expand Down
5 changes: 0 additions & 5 deletions docker-compose.yml

This file was deleted.

3 changes: 1 addition & 2 deletions fqn_decorators/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
# -*- coding: utf-8 -*-
from .decorators import *
from .decorators import * # noqa: F403, F401
33 changes: 13 additions & 20 deletions fqn_decorators/decorators.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import functools
import sys

Expand All @@ -9,29 +8,23 @@ def get_fqn(obj):
It only works for classes, methods and functions.
It is unable to properly determine the FQN of class instances, static methods and class methods.
"""
path = [getattr(obj, "__module__", None)]
qualname = getattr(obj, "__qualname__", None)
if qualname:
path.append(qualname.replace("<locals>.", ""))
im_self = getattr(obj, "__self__", None)
im_class = getattr(im_self, "__class__", None)
if im_self and im_class:
path = [
getattr(im_class, "__module__", None),
getattr(im_class, "__name__", None),
getattr(obj, "__name__", None),
]
im_self = getattr(obj, "__self__", None)
im_class = getattr(im_self, "__class__", None)
if im_self and im_class:
path = [
getattr(im_class, "__module__", None),
getattr(im_class, "__name__", None),
getattr(obj, "__name__", None),
]
else:
im_class = getattr(obj, "im_class", None)
im_class_module = getattr(im_class, "__module__", None)
if im_class and im_class_module:
path = [im_class_module]
path.append(getattr(im_class, "__name__", None))
path.append(getattr(obj, "__name__", None))
path = [
getattr(obj, "__module__", None),
getattr(obj, "__qualname__", "").replace("<locals>.", ""),
]
return ".".join(filter(None, path))


class Decorator(object):
class Decorator:
"""
A base class to easily create decorators.
"""
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.black]
line-length = 120
target_version = ["py27", "py35", "py36", "py37"]
target_version = ["py36", "py37", "py38"]

[tool.isort]
combine_as_imports = true
Expand Down
8 changes: 5 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
# Package in develop mode
-e .

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

# Distribution
twine
wheel

# Code style
mypy; python_version >= '3.5'
mypy
isort[pyproject]
flake8
black

# Tests
tox
tox==3.20.1
pytest
pytest-cov
pytest-asyncio; python_version >= '3.5'
Expand Down
10 changes: 5 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from setuptools import find_packages, setup

# setuptools doesn't support type hints for now:
# https://github.com/pypa/setuptools/issues/2345
# so we ignoring mypy checks on this package
from setuptools import find_packages, setup # type: ignore

with open("README.md") as f:
long_description = f.read()
Expand All @@ -26,10 +29,7 @@
"Intended Audience :: Developers",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
Expand Down
1 change: 0 additions & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
# -*- coding: utf-8 -*-
2 changes: 0 additions & 2 deletions tests/conftest.py

This file was deleted.

4 changes: 2 additions & 2 deletions tests/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ def my_test_func(a):


@fqn_decorators.Decorator()
class A(object):
class A:
@fqn_decorators.Decorator
def method(self, a):
return a


class B(object):
class B:
@fqn_decorators.Decorator
def method(self, b):
return b
Loading

0 comments on commit 7e9541a

Please sign in to comment.