Migrate to pyproject and created a docker dev environment

This commit is contained in:
Alvaro Mariano 2023-05-29 21:26:00 -03:00
parent a1cdb890a3
commit d87d2e810b
15 changed files with 1378 additions and 317 deletions

2
.gitignore vendored
View file

@ -13,3 +13,5 @@ htmlcov
.venv/
test.sqlite3
settings.json
.pytest_cache
.vscode

28
.pre-commit-config.yaml Normal file
View file

@ -0,0 +1,28 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
- repo: https://github.com/pylint-dev/pylint
rev: v2.17.4
hooks:
- id: pylint
- repo: https://github.com/PyCQA/bandit
rev: 1.7.5
hooks:
- id: bandit
args: ["-c", "pyproject.toml"]

134
.pylintrc
View file

@ -1,134 +0,0 @@
[MASTER]
extension-pkg-whitelist=
ignore=CVS
ignore-patterns=
#init-hook=
jobs=4
load-plugins=
persistent=yes
#rcfile=
unsafe-load-any-extension=no
[MESSAGES CONTROL]
confidence=
disable=no-member,locally-disabled,too-few-public-methods,too-many-ancestors,keyword-arg-before-vararg
enable=
[REPORTS]
evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
msg-template={path}:{line}: [{msg_id}({symbol}), {obj}] {msg}
output-format=text
reports=no
score=no
[REFACTORING]
max-nested-blocks=5
[FORMAT]
expected-line-ending-format=
ignore-long-lines=^\s*(# )?<?https?://\S+>?$
indent-after-paren=4
indent-string=' '
max-line-length=120
max-module-lines=300
no-space-check=
single-line-class-stmt=no
single-line-if-stmt=no
[VARIABLES]
additional-builtins=
allow-global-unused-variables=yes
callbacks=cb_,_cb
dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_
ignored-argument-names=_.*|^ignored_|^unused_
init-import=yes
redefining-builtins-modules=six.moves,future.builtins
[MISCELLANEOUS]
notes=
[SPELLING]
spelling-dict=
spelling-ignore-words=
spelling-private-dict-file=
spelling-store-unknown-words=no
[BASIC]
argument-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
argument-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
attr-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
attr-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
bad-names=foo,bar,baz,toto,tutu,tata
class-attribute-name-hint=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$
class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$
class-name-hint=[A-Z_][a-zA-Z0-9]+$
class-rgx=[A-Z_][a-zA-Z0-9]+$
const-name-hint=(([A-Z_][A-Z0-9_]*)|(__.*__))$
const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$
docstring-min-length=20
function-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
function-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
good-names=i,j,k,ex,Run,_,urlpatterns,app_name,register,application
include-naming-hint=no
inlinevar-name-hint=[A-Za-z_][A-Za-z0-9_]*$
inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$
method-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
method-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
module-name-hint=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
name-group=
no-docstring-rgx=^_
property-classes=abc.abstractproperty
variable-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
variable-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
[SIMILARITIES]
ignore-comments=no
ignore-docstrings=no
ignore-imports=no
min-similarity-lines=2
[LOGGING]
logging-modules=logging
[TYPECHECK]
contextmanager-decorators=contextlib.contextmanager
generated-members=
ignore-mixin-members=yes
ignore-on-opaque-inference=yes
ignored-classes=optparse.Values,thread._local,_thread._local
ignored-modules=
missing-member-hint=yes
missing-member-hint-distance=1
missing-member-max-choices=1
[DESIGN]
max-args=5
max-attributes=7
max-bool-expr=5
max-branches=12
max-locals=15
max-parents=7
max-public-methods=30
max-returns=6
max-statements=50
min-public-methods=1
[CLASSES]
defining-attr-methods=__init__,__new__,setUp
exclude-protected=_asdict,_fields,_replace,_source,_make
valid-classmethod-first-arg=cls
valid-metaclass-classmethod-first-arg=mcs
[IMPORTS]
allow-wildcard-with-all=no
analyse-fallback-blocks=yes
deprecated-modules=optparse,tkinter.tix
ext-import-graph=
import-graph=
int-import-graph=
known-standard-library=
known-third-party=enchant
[EXCEPTIONS]
overgeneral-exceptions=Exception

View file

@ -1,31 +0,0 @@
language: python
python:
- "3.5"
- "3.6"
- "3.7"
- "3.8"
env:
- DJANGO=2.2
- DJANGO=3.0
install:
# command to install dependencies
- "pip install coveralls"
- "pip install pytz" # Needed for tests
- pip install -q Django==$DJANGO
- "pip install ."
# command to run tests
script:
- SAMPLE_APP=1 coverage run --branch --source=notifications manage.py test
- coverage run --branch --source=notifications manage.py test
matrix:
exclude:
- python: "3.5"
env: DJANGO=3.0
after_success:
- coveralls

View file

@ -1,42 +0,0 @@
Justin Quick <justquick@gmail.com>
Aaron Williamson
Jordan Reiter
Manuel Aristaran
Darrell Hoy
Ken "Elf" Mathieu Sternberg
Josh Ourisman
Trever Shick
Sandip Agrawal
Piet Delport
Steve Ivy
Ben Slavin
Jason Culverhouse
Dave Harrington
Pedro Bur—n
Ryan Quigley
Neelesh Shastry
David Gouldin <david@gould.in>
Donald Stufft
Nolan Brubaker
Herman Schaaf
Walter Scheper
Chris Beaven
Vineet Naik
Walter Scheper
Yang Yubo (https://github.com/yangyubo)
Matthew Schinckel (https://github.com/schinckel)
Mirat Can Bayrak (https://github.com/miratcan)
Konrad Hałas (https://github.com/konradhalas)
Peppe Bergqvist (https://github.com/peppelorum)
Daniel Shapiro (https://github.com/danxshap)
randomfish (https://github.com/randomfish)
Adriaan (https://github.com/ChocolateCookies)
Sandro Rodrigues (https://github.com/srtab)
Jesper Håkansson (https://github.com/drager)
Fábio C. Barrionuevo da Luz (https://github.com/luzfcb)
fay (https://github.com/fay)
blag (https://github.com/blag)
Zhongyuan Zhang (https://github.com/zhang-z)
Samuel Spencer (https://github.com/LegoStormtroopr)

View file

@ -1,2 +0,0 @@
include MANIFEST.in README.md AUTHORS.txt LICENSE.txt CHANGELOG.md
recursive-include notifications *.py *.html *.txt *.po

8
Makefile Normal file
View file

@ -0,0 +1,8 @@
up:
docker-compose run --remove-orphans --rm --service-ports development
tests:
poetry run python -m tox run-parallel
server:
poetry run python manage.py runserver 0.0.0.0:8000

10
docker-compose.yaml Normal file
View file

@ -0,0 +1,10 @@
version: "3.9"
services:
development:
build: .
stdin_open: true
tty: true
volumes:
- .:/django-notifications
ports:
- "8000:8000"

23
dockerfile Normal file
View file

@ -0,0 +1,23 @@
#!/bin/sh
FROM python:3.11-slim-buster
SHELL ["/bin/bash", "-c"]
RUN apt-get update
RUN apt-get install -y curl git gcc make zlib1g-dev libssl-dev libffi-dev sqlite3 libsqlite3-dev liblzma-dev
RUN pip install --upgrade pip
RUN curl -sSL https://install.python-poetry.org | python3 -
RUN curl https://pyenv.run | bash
ENV PATH ~/.pyenv/shims:~/.pyenv/bin:/root/.local/bin:$PATH
RUN eval "$(pyenv init -)"
RUN pyenv install 3.8 3.9 3.10
WORKDIR /django-notifications
RUN pyenv local system 3.8 3.9 3.10
RUN apt-get --purge autoremove -y gnupg; \
rm -rf /var/cache/apt/lists;
ENTRYPOINT poetry install && poetry run pre-commit install && /bin/bash

1144
poetry.lock generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -1,22 +0,0 @@
strictness: veryhigh
ignore-paths:
- migrations
- build
- dist
- django_notifications_hq.egg-info
uses:
- django
pep8:
full: true
options:
max-line-length: 120
pylint:
full: true
mccabe:
disable:
- MC0001

155
pyproject.toml Normal file
View file

@ -0,0 +1,155 @@
[tool.poetry]
name = "django-notifications-hq"
version = "2.0.0"
description = "GitHub notifications alike app for Django."
authors = [
"Justin Quick <justquick@gmail.com>",
"Yang Yubo <yang@yangyubo.com>",
]
maintainers = [
# Team members
"Alvaro Mariano <https://github.com/AlvaroLQueiroz>",
"Samuel Spencer <https://github.com/LegoStormtroopr)>",
"YPCrumble <https://github.com/YPCrumble>",
# Contributors
"Adriaan <https://github.com/ChocolateCookies>",
"blag <https://github.com/blag>",
"Dan DeFelippi <https://github.com/driverdan>",
"Daniel Shapiro <https://github.com/danxshap>",
"Fábio C. Barrionuevo da Luz <https://github.com/luzfcb>",
"fay <https://github.com/fay>",
"Jesper Håkansson <https://github.com/drager>",
"Konrad Hałas <https://github.com/konradhalas>",
"Matthew Schinckel <https://github.com/schinckel>",
"Mirat Can Bayrak <https://github.com/miratcan>",
"Peppe Bergqvist <https://github.com/peppelorum>",
"randomfish <https://github.com/randomfish>",
"Sandro Rodrigues <https://github.com/srtab>",
"Utkucan Bıyıklı <https://github.com/UtkucanBykl>",
"Zhongyuan Zhang <http://github.com/zhang-z>",
]
license = "MIT"
readme = "README.md"
homepage = "https://pypi.org/project/django-notifications-hq"
documentation = "https://pypi.org/project/django-notifications-hq"
repository = "https://github.com/django-notifications/django-notifications"
keywords = [
"django",
"notifications",
"github",
"action",
"event",
"stream",
]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Environment :: Web Environment",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Natural Language :: English",
"Framework :: Django",
"Framework :: Django :: 3.2",
"Framework :: Django :: 4.0",
"Framework :: Django :: 4.1",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Topic :: Communications :: Notification",
"Topic :: Internet",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Software Development :: Libraries",
"Topic :: Utilities",
]
packages = [
{include = "notifications/*.py"},
{include = "notifications/base/"},
{include = "notifications/migrations/"},
{include = "notifications/templatetags/"},
{include = "notifications/templatetags/"},
]
include = [
"CHANGELOG.md",
"notifications/locale/",
"notifications/static/",
"notifications/templates/",
]
[tool.poetry.dependencies]
python = "^3.8.1"
django = ">3.2"
swapper = "^1"
[tool.poetry.group.dev.dependencies]
black = "^23"
bandit = "^1"
coverage = "^7"#### TODO
django-debug-toolbar = "^4"
isort = "^5"
mypy = "^1" ### TODO
pre-commit = "^3"
pylint = "^2"
pylint-django = "^2"
pytest = "^7"
pytest-cov = "^4"
pytest-django = "^4"
pytz = "^2023.3"
tox = "^4"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
[tool.pylint.MASTER]
load-plugins = [
"pylint_django"
]
[tool.pylint.'MESSAGES CONTROL']
disable = [
]
[tool.pylint.FORMAT]
max-line-length = 120
[tool.black]
line-length = 120
[tool.isort]
profile = "black"
[tool.bandit]
skips = ["B106"]
[tool.bandit.assert_used]
skips = ["*test*.py"]
[tool.pytest.ini_options]
minversion = "7.0"
addopts = "-ra -q"
norecursedirs = [
".git",
".github",
".idea",
".pytest_cache",
".tox",
".vscode",
"dist",
"django_notifications_hq.egg-info",
]
python_files = [
"tests.py",
"test_*.py",
"*_tests.py",
]
testpaths = [
"tests",
"integration",
]
DJANGO_SETTINGS_MODULE = "notifications.tests.settings"

View file

@ -1,5 +0,0 @@
[bdist_wheel]
# This flag says that the code is written to work on both Python 2 and Python
# 3. If at all possible, it is good practice to do this. If you cannot, you
# will need to generate wheels for each Python version that you support.
universal=1

View file

@ -1,73 +0,0 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
''' Django notification setup file for pip package '''
import ast
import re
try:
from setuptools import setup
except ImportError:
from distutils.core import setup # pylint: disable=no-name-in-module,import-error
_version_re = re.compile(r'__version__\s+=\s+(.*)') # pylint: disable=invalid-name
with open('notifications/__init__.py', 'rb') as f:
version = str(ast.literal_eval(_version_re.search( # pylint: disable=invalid-name
f.read().decode('utf-8')).group(1)))
setup(
name='django-notifications-hq',
version=version,
description='GitHub notifications alike app for Django.',
long_description=open('README.md').read(),
long_description_content_type="text/markdown",
author='django-notifications team',
author_email='yang@yangyubo.com',
url='http://github.com/django-notifications/django-notifications',
install_requires=[
'django>=3.2',
'django-model-utils>=3.1.0',
'jsonfield>=2.1.0',
'pytz',
'swapper'
],
test_requires=[
'django>=3.2',
'django-model-utils>=3.1.0',
'jsonfield>=2.1.0',
'pytz'
],
packages=[
'notifications',
'notifications.base',
'notifications.templatetags',
'notifications.migrations',
],
include_package_data=True,
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Web Environment',
'Framework :: Django',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Framework :: Django',
'Framework :: Django :: 3.2',
'Framework :: Django :: 4.0',
'Framework :: Django :: 4.1',
# Specify the Python versions you support here. In particular, ensure
# that you indicate whether you support Python 2, Python 3 or both.
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Topic :: Utilities'
],
keywords='django notifications github action event stream',
license='MIT',
)

16
tox.ini
View file

@ -1,17 +1,17 @@
# -- FILE: tox.ini
[tox]
min_version = 4.0
isolated_build = true
skip_missing_interpreters = False
envlist =
py{37,38,39,310,311}-django32
py{38,39,310}-django40
py{38,39,310,311}-django41
python{3.8,3.9,3.10,3.11}-django{32,40,41}
[gh-actions]
python =
3.7: py37
3.8: py38
3.9: py39
3.10: py310
3.11: py311
3.8: python3.8
3.9: python3.9
3.10: python3.10
3.11: python3.11
[testenv]
commands =