misc: import project skeleton

This commit is contained in:
Corentin Sechet 2023-01-10 10:05:21 +01:00
commit 0b5d05411a
10 changed files with 220 additions and 0 deletions

7
.flake8 Normal file
View File

@ -0,0 +1,7 @@
[flake8]
ignore =
# at least two spaces before inline comment
E261
max-complexity = 10
max-line-length = 110
exclude = .nox,.venv

8
.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
**/__pycache__
.build
.eggs
.mypy_cache
.venv
build
dist
stylo.egg-info

11
.pre-commit-config.yaml Normal file
View File

@ -0,0 +1,11 @@
repos:
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
args: ['--target-version', 'py37', '--skip-string-normalization', '--line-length', '110']
- repo: https://github.com/PyCQA/isort
rev: 5.7.0
hooks:
- id: isort
args: ['--profile', 'black', '--line-length', '110']

0
README.md Normal file
View File

90
noxfile.py Normal file
View File

@ -0,0 +1,90 @@
"""Nox configuration file"""
from os import fsdecode
from pathlib import Path
import nox
from nox import Session
nox.options.sessions = ["checks"]
LINT_PATHS = ["stylo", "tests"]
VENV_DIR = Path(".venv")
@nox.session(python=["3.10"], reuse_venv=True)
def tests(session: Session) -> None:
"""Run unit tests."""
session.install("-e", ".[dev]")
session.run("pytest")
@nox.session(reuse_venv=True)
def black(session: Session) -> None:
"""Check black formatting."""
session.install("black")
session.run("black", "--check", *LINT_PATHS)
@nox.session(reuse_venv=True)
def flake8(session: Session) -> None:
"""Run flake8"""
session.install("flake8")
session.run("flake8", *LINT_PATHS)
@nox.session(reuse_venv=True)
def isort(session: Session) -> None:
"""Check imports sorting"""
session.install("isort")
session.run("isort", "--check", *LINT_PATHS)
@nox.session(reuse_venv=True)
def mypy(session: Session) -> None:
"""Run Mypy"""
session.install("mypy", "-e", ".[dev]")
session.run("mypy", "--install-types", *LINT_PATHS)
@nox.session(reuse_venv=True)
def pylint(session: Session) -> None:
"""Run pylint"""
session.install("pylint", "-e", ".[dev]")
session.run("pylint", "--rcfile=pyproject.toml", *LINT_PATHS)
@nox.session(python=False)
def lint(session: Session) -> None:
"""Run all lint tasks"""
session.notify("black")
session.notify("flake8")
session.notify("isort")
session.notify("mypy")
session.notify("pylint")
@nox.session(python=False)
def checks(session: Session) -> None:
"""Run all checks"""
session.notify("lint")
session.notify("tests")
@nox.session(python=False)
def dev(session: Session) -> None:
"""
Sets up a python development environment for the project.
"""
session.run(
"python3",
"-m",
"virtualenv",
"-p",
"python3.10",
fsdecode(VENV_DIR),
silent=True,
)
python_path = Path.cwd() / VENV_DIR / "bin/python"
python = fsdecode(python_path)
session.run(python, "-m", "pip", "install", "-e", ".[dev]", external=True, silent=True)

24
pyproject.toml Normal file
View File

@ -0,0 +1,24 @@
[tool.pylint.messages_control]
max-line-length = 80
disable = [
"fixme",
"invalid-name",
"missing-docstring",
"too-few-public-methods",
"duplicate-code"
]
[tool.isort]
profile = "black"
src_paths = ["stylo", "tests", "noxfile.py"]
[tool.mypy]
strict = true
files = "stylo/**/*.py,tests/**/*.py,noxfile.py"
[tool.pylint]
max-line-length = 110
[tool.pytest.ini_options]
asyncio_mode = "auto"

43
setup.py Executable file
View File

@ -0,0 +1,43 @@
#!/usr/bin/python
"""stylo setup."""
from pathlib import Path
from setuptools import setup
setup(
name="stylo",
description="",
long_description=(Path(__file__).parent / "README.md").read_text(),
long_description_content_type="text/markdown",
keywords=["front-end"],
packages=[
"stylo",
],
entry_points={
"console_scripts": [
"stylo=stylo.__main__:main",
],
},
license="GPL",
classifiers=[
"Development Status :: 2 - Pre-Alpha",
"Intended Audience :: Developers",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3.8",
],
install_requires=["click"],
extras_require={
"dev": [
"nox",
"pytest",
"pytest-asyncio",
]
},
author="Entr'ouvert",
author_email="csechet@entrouvert.com",
zip_safe=False,
setuptools_git_versioning={
"enabled": True,
},
)

1
stylo/__init__.py Normal file
View File

@ -0,0 +1 @@
""" Core module for Stylo"""

35
stylo/cli.py Normal file
View File

@ -0,0 +1,35 @@
"""frontools main module"""
from asyncio import run
from functools import update_wrapper
from logging import INFO, basicConfig, getLogger
from typing import Any
from click import Context as ClickContext
from click import group, pass_context
def _async_command(function: Any) -> Any:
def wrapper(*args: Any, **kwargs: Any) -> Any:
return run(function(*args, **kwargs))
return update_wrapper(wrapper, function)
_LOGGER = getLogger(__file__)
@group()
@pass_context
@_async_command
async def main(_: ClickContext) -> None:
"""Utilities for EO frontend development."""
basicConfig(format="%(message)s", level=INFO)
@main.command(name="lint")
def lint() -> None:
"""Lint CSS files frontools caches"""
if __name__ == "__main__":
main() # pylint: disable=no-value-for-parameter

1
tests/__init__.py Normal file
View File

@ -0,0 +1 @@
"""Stylo unit tests packages"""