Skip to content
This repository was archived by the owner on Jul 27, 2022. It is now read-only.

Commit 02bff70

Browse files
committed
Initial Skaffolding
1 parent 1dd4e22 commit 02bff70

File tree

15 files changed

+1336
-0
lines changed

15 files changed

+1336
-0
lines changed

.flake8

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[flake8]
2+
select = ANN,B,B9,BLK,C,D,DAR,E,F,I,S,W
3+
ignore = E203,E501,W503,I100,I202
4+
max-line-length = 120
5+
max-complexity = 10
6+
application-import-names = hypermodern_python,tests
7+
import-order-style = google
8+
docstring-convention = google
9+
per-file-ignores = tests/*:S101

.github/workflows/test-pypi.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: TestPyPI
2+
on:
3+
push:
4+
branches:
5+
- master
6+
jobs:
7+
test_pypi:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v2
11+
- uses: actions/setup-python@v1
12+
with:
13+
python-version: '3.8'
14+
architecture: x64
15+
- run: pip install poetry==1.0.5
16+
- run: >-
17+
poetry version patch &&
18+
version=$(poetry version | awk '{print $2}') &&
19+
poetry version $version.dev.$(date +%s)
20+
- run: poetry build
21+
- uses: pypa/[email protected]
22+
with:
23+
user: __token__
24+
password: ${{ secrets.TEST_PYPI_TOKEN }}
25+
repository_url: https://test.pypi.org/legacy/

.github/workflows/tests.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Tests
2+
on: push
3+
jobs:
4+
tests:
5+
runs-on: ubuntu-latest
6+
strategy:
7+
matrix:
8+
python-version: ['3.7', '3.8']
9+
name: Python ${{ matrix.python-version }}
10+
steps:
11+
- uses: actions/checkout@v2
12+
- uses: actions/setup-python@v1
13+
with:
14+
python-version: ${{ matrix.python-version }}
15+
architecture: x64
16+
- run: pip install nox==2019.11.9
17+
- run: pip install poetry==1.0.5
18+
- run: nox

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,4 @@ dmypy.json
127127

128128
# Pyre type checker
129129
.pyre/
130+
/.pytype/

.pre-commit-config.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v2.3.0
4+
hooks:
5+
- id: check-yaml
6+
- id: end-of-file-fixer
7+
- id: trailing-whitespace
8+
- repo: local
9+
hooks:
10+
- id: black
11+
name: black
12+
entry: poetry run black
13+
language: system
14+
types: [python]
15+
- id: flake8
16+
name: flake8
17+
entry: poetry run flake8
18+
language: system
19+
types: [python]

.vscode/settings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"python.pythonPath": "/Users/eliehamouche/Library/Caches/pypoetry/virtualenvs/twint-6K2DqBGp-py3.8",
3+
"python.formatting.provider": "black"
4+
}

mypy.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[mypy]
2+
3+
[mypy-desert,marshmallow,nox.*,pytest,pytest_mock,_pytest.*]
4+
ignore_missing_imports = True

noxfile.py

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
"""Nox sessions."""
2+
import tempfile
3+
from typing import Any
4+
5+
import nox
6+
from nox.sessions import Session
7+
8+
package = "twint"
9+
nox.options.sessions = "lint", "mypy", "pytype", "tests"
10+
locations = "src", "tests", "noxfile.py"
11+
12+
13+
def install_with_constraints(session: Session, *args: str, **kwargs: Any) -> None:
14+
"""Install packages constrained by Poetry's lock file.
15+
16+
This function is a wrapper for nox.sessions.Session.install. It
17+
invokes pip to install packages inside of the session's virtualenv.
18+
Additionally, pip is passed a constraints file generated from
19+
Poetry's lock file, to ensure that the packages are pinned to the
20+
versions specified in poetry.lock. This allows you to manage the
21+
packages as Poetry development dependencies.
22+
23+
Arguments:
24+
session: The Session object.
25+
args: Command-line arguments for pip.
26+
kwargs: Additional keyword arguments for Session.install.
27+
28+
"""
29+
with tempfile.NamedTemporaryFile() as requirements:
30+
session.run(
31+
"poetry",
32+
"export",
33+
"--dev",
34+
"--format=requirements.txt",
35+
f"--output={requirements.name}",
36+
external=True,
37+
)
38+
session.install(f"--constraint={requirements.name}", *args, **kwargs)
39+
40+
41+
@nox.session(python="3.8")
42+
def black(session: Session) -> None:
43+
"""Run black code formatter."""
44+
args = session.posargs or locations
45+
install_with_constraints(session, "black")
46+
session.run("black", *args)
47+
48+
49+
@nox.session(python=["3.8", "3.7"])
50+
def lint(session: Session) -> None:
51+
"""Lint using flake8."""
52+
args = session.posargs or locations
53+
install_with_constraints(
54+
session,
55+
"flake8",
56+
"flake8-annotations",
57+
"flake8-bandit",
58+
"flake8-black",
59+
"flake8-bugbear",
60+
"flake8-docstrings",
61+
"flake8-import-order",
62+
)
63+
session.run("flake8", *args)
64+
65+
66+
@nox.session(python=["3.8", "3.7"])
67+
def mypy(session: Session) -> None:
68+
"""Type-check using mypy."""
69+
args = session.posargs or locations
70+
install_with_constraints(session, "mypy")
71+
session.run("mypy", *args)
72+
73+
74+
@nox.session(python="3.7")
75+
def pytype(session: Session) -> None:
76+
"""Type-check using pytype."""
77+
args = session.posargs or ["--disable=import-error", *locations]
78+
install_with_constraints(session, "pytype")
79+
session.run("pytype", *args)
80+
81+
82+
@nox.session(python=["3.8", "3.7"])
83+
def tests(session: Session) -> None:
84+
"""Run the test suite."""
85+
args = session.posargs or ["--cov", "-m", "not e2e"]
86+
session.run("poetry", "install", "--no-dev", external=True)
87+
install_with_constraints(
88+
session, "coverage[toml]", "pytest", "pytest-cov", "pytest-mock"
89+
)
90+
session.run("pytest", *args)
91+
92+
93+
@nox.session(python=["3.8", "3.7"])
94+
def typeguard(session: Session) -> None:
95+
"""Runtime type checking using Typeguard."""
96+
args = session.posargs or ["-m", "not e2e"]
97+
session.run("poetry", "install", "--no-dev", external=True)
98+
install_with_constraints(session, "pytest", "pytest-mock", "typeguard")
99+
session.run("pytest", f"--typeguard-packages={package}", *args)
100+
101+
102+
# @nox.session(python="3.8")
103+
# def coverage(session: Session) -> None:
104+
# """Upload coverage data."""
105+
# install_with_constraints(session, "coverage[toml]", "codecov")
106+
# session.run("coverage", "xml", "--fail-under=0")
107+
# session.run("codecov", *session.posargs)

0 commit comments

Comments
 (0)