Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 31 additions & 18 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ auto_cancellation: false
env:
PATH: ${HOME}/.local/bin:${PATH}
# ^ add user paths
COVERALLS_REPO_TOKEN: ENCRYPTED[93a2e96a39f5179862d8bd0ee99000dd18df330c2cf0123d3486569b34f2752fbb45085a9e034df76bcee6d13a14ced3]
# ^ ADD YOUR ENCRYPTED TOKEN HERE: https://cirrus-ci.org/guide/writing-tasks/#encrypted-variables
# COVERALLS_REPO_TOKEN: ENCRYPTED[]
# ^ You can add an encrypted token or use CirrusCI web interface to set the variable
# See discussion in: https://github.com/cirruslabs/cirrus-ci-docs/discussions/866
TYPE_CHECKING: true # Enable/disable type checking
PIP_CACHE: ${HOME}/.cache/pip
LC_ALL: C.UTF-8
LANG: C.UTF-8
Expand Down Expand Up @@ -42,36 +43,49 @@ env:
# ^ tox is better if invoked as a module on Windows/OSX


# Deep clone script for POSIX environments (required for setuptools-scm)
.clone_script: &clone |
if [ -z "$CIRRUS_PR" ]; then
git clone --recursive --branch=$CIRRUS_BRANCH https://x-access-token:${CIRRUS_REPO_CLONE_TOKEN}@github.com/${CIRRUS_REPO_FULL_NAME}.git $CIRRUS_WORKING_DIR
git reset --hard $CIRRUS_CHANGE_IN_REPO
else
git clone --recursive https://x-access-token:${CIRRUS_REPO_CLONE_TOKEN}@github.com/${CIRRUS_REPO_FULL_NAME}.git $CIRRUS_WORKING_DIR
git fetch origin pull/$CIRRUS_PR/head:pull/$CIRRUS_PR
git reset --hard $CIRRUS_CHANGE_IN_REPO
fi


# ---- Task definitions ----

typecheck_task:
name: typecheck (Linux - 3.9)
only_if: $TYPE_CHECKING == 'true'
clone_script: *clone
container: {image: "python:3.9-buster"} # most recent => better type support
pip_cache: *pip-cache
mypy_cache:
folder: .mypy_cache
tox_install_script:
- python -m pip install --upgrade pip setuptools tox
prepare_script: *prepare
typecheck_script:
- python -m tox -e typecheck


linux_mac_task:
# Use custom cloning since otherwise git tags are missing
clone_script: &clone |
if [ -z "$CIRRUS_PR" ]; then
git clone --recursive --branch=$CIRRUS_BRANCH https://x-access-token:${CIRRUS_REPO_CLONE_TOKEN}@github.com/${CIRRUS_REPO_FULL_NAME}.git $CIRRUS_WORKING_DIR
git reset --hard $CIRRUS_CHANGE_IN_REPO
else
git clone --recursive https://x-access-token:${CIRRUS_REPO_CLONE_TOKEN}@github.com/${CIRRUS_REPO_FULL_NAME}.git $CIRRUS_WORKING_DIR
git fetch origin pull/$CIRRUS_PR/head:pull/$CIRRUS_PR
git reset --hard $CIRRUS_CHANGE_IN_REPO
fi
clone_script: *clone
matrix:
- name: test (Linux - 3.6)
container: {image: "python:3.6-buster"}
install_script: &debian-install
- apt-get install -y git
- name: test (Linux - 3.7)
container: {image: "python:3.7-buster"}
install_script: *debian-install
- name: test (Linux - 3.8)
container: {image: "python:3.8-buster"}
install_script: *debian-install
- name: test (Linux - 3.9)
container: {image: "python:3.9-buster"}
install_script: *debian-install
- name: test (Linux - Anaconda)
container: {image: "continuumio/anaconda3:2021.05"}
install_script: *debian-install
extra_install_script:
- conda install -y -c conda-forge virtualenv build setuptools setuptools-scm pip tox
- name: test (OS X)
Expand Down Expand Up @@ -166,7 +180,6 @@ coverage_task:
- test (Linux - 3.8)
- test (Linux - Anaconda)
- test (OS X)
install_script: *debian-install
pip_install_script:
pip install --user --upgrade coverage coveralls pre-commit
precommit_script:
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@ repos:
]

- repo: https://github.com/pycqa/isort
rev: 5.9.2
rev: 5.9.3
hooks:
- id: isort

- repo: https://github.com/psf/black
rev: 21.7b0
rev: 21.8b0
hooks:
- id: black
language_version: python3

- repo: https://github.com/asottile/blacken-docs
rev: v1.10.0
rev: v1.11.0
hooks:
- id: blacken-docs
additional_dependencies: [black]
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,5 @@ Don't forget to tell your contributors to also install and use pre-commit.
Note
====

This project has been set up using PyScaffold 4.0.2.post1.dev60+g1585605. For details and usage
This project has been set up using PyScaffold 4.1rc1. For details and usage
information on PyScaffold see https://pyscaffold.org/.
15 changes: 14 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,24 @@ exclude =
.eggs
docs/conf.py

[mypy]
pretty = True
show_error_codes = True
show_error_context = True
show_traceback = True
ignore_missing_imports = True
warn_redundant_casts = True
warn_unused_ignores = True
# Add here plugins
# plugins = mypy_django_plugin.main, returns.contrib.mypy.returns_plugin

[pyscaffold]
# PyScaffold's parameters when the project was created.
# This will be used when updating. Do not change!
version = 4.0.2.post1.dev60+g1585605
version = 4.1rc1.post1.dev18+g423b773
package = ci_tester
extensions =
cirrus
pre_commit
typed
typed = True
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Setup file for ci-tester.
Use setup.cfg to configure your project.

This file was generated with PyScaffold 4.0.2.post1.dev60+g1585605.
This file was generated with PyScaffold 4.1rc1.post1.dev18+g423b773.
PyScaffold helps you to put up the scaffold of your new Python project.
Learn more under: https://pyscaffold.org/
"""
Expand Down
Empty file added src/ci_tester/py.typed
Empty file.
15 changes: 8 additions & 7 deletions src/ci_tester/skeleton.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import argparse
import logging
import sys
from typing import List # required for Python < 3.9

from ci_tester import __version__

Expand All @@ -40,7 +41,7 @@
# when using this Python module as a library.


def fib(n):
def fib(n: int) -> int:
"""Fibonacci example function

Args:
Expand All @@ -62,7 +63,7 @@ def fib(n):
# executable/script.


def parse_args(args):
def parse_args(args: List[str]) -> argparse.Namespace:
"""Parse command line parameters

Args:
Expand Down Expand Up @@ -98,7 +99,7 @@ def parse_args(args):
return parser.parse_args(args)


def setup_logging(loglevel):
def setup_logging(loglevel: int):
"""Setup basic logging

Args:
Expand All @@ -110,7 +111,7 @@ def setup_logging(loglevel):
)


def main(args):
def main(args: List[str]):
"""Wrapper allowing :func:`fib` to be called with string arguments in a CLI fashion

Instead of returning the value from :func:`fib`, it prints the result to the
Expand All @@ -120,10 +121,10 @@ def main(args):
args (List[str]): command line parameters as list of strings
(for example ``["--verbose", "42"]``).
"""
args = parse_args(args)
setup_logging(args.loglevel)
params = parse_args(args)
setup_logging(params.loglevel)
_logger.debug("Starting crazy calculations...")
print("The {}-th Fibonacci number is {}".format(args.n, fib(args.n)))
print("The {}-th Fibonacci number is {}".format(params.n, fib(params.n)))
_logger.info("Script ends here")


Expand Down
15 changes: 13 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
[tox]
minversion = 3.15
envlist = default
isolated_build = True


[testenv]
description = Invoke pytest to run automated tests
isolated_build = True
setenv =
TOXINIDIR = {toxinidir}
passenv =
Expand All @@ -20,6 +20,18 @@ commands =
pytest {posargs}


[testenv:typecheck]
description = invoke mypy to typecheck the source code
changedir = {toxinidir}
passenv =
TERM
# ^ ensure colors
deps =
mypy
commands =
python -m mypy {posargs:src/}


[testenv:{build,clean}]
description =
build: Build the package in isolation according to PEP517, see https://github.com/pypa/build
Expand All @@ -42,7 +54,6 @@ description =
docs: Invoke sphinx-build to build the docs
doctests: Invoke sphinx-build to run doctests
linkcheck: Check for broken links in the documentation
usedevelop = True
setenv =
DOCSDIR = {toxinidir}/docs
BUILDDIR = {toxinidir}/docs/_build
Expand Down