From 88c95659aed183c2657c37b3aaebbf20e343a64c Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Fri, 10 Sep 2021 14:26:03 +0100 Subject: [PATCH 1/3] Companion PR to test changes introduced in PyScaffold#494 --- .cirrus.yml | 33 +++++++++++++++------------------ .pre-commit-config.yaml | 6 +++--- README.rst | 2 +- setup.cfg | 2 +- setup.py | 2 +- tox.ini | 3 +-- 6 files changed, 22 insertions(+), 26 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index f61d9e9..781c83d 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -7,8 +7,8 @@ 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 PIP_CACHE: ${HOME}/.cache/pip LC_ALL: C.UTF-8 @@ -42,36 +42,34 @@ 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 ---- 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) @@ -166,7 +164,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: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 21ec0f9..457f46e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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] diff --git a/README.rst b/README.rst index 73f6cca..12d2ef8 100644 --- a/README.rst +++ b/README.rst @@ -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/. diff --git a/setup.cfg b/setup.cfg index 713a2c1..4da1221 100644 --- a/setup.cfg +++ b/setup.cfg @@ -121,7 +121,7 @@ exclude = [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.dev1+gd709939 package = ci_tester extensions = cirrus diff --git a/setup.py b/setup.py index 8d0f8c9..b11612c 100644 --- a/setup.py +++ b/setup.py @@ -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.dev1+gd709939. PyScaffold helps you to put up the scaffold of your new Python project. Learn more under: https://pyscaffold.org/ """ diff --git a/tox.ini b/tox.ini index d12958d..fe005ad 100644 --- a/tox.ini +++ b/tox.ini @@ -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 = @@ -42,7 +42,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 From 4a130f24fce5b9143b12c185df9f6dfcd6983714 Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Fri, 10 Sep 2021 14:36:55 +0100 Subject: [PATCH 2/3] Companion PR to test changes introduced in PyScaffold#493 --- .cirrus.yml | 14 ++++++++++++++ setup.cfg | 13 ++++++++++++- setup.py | 2 +- src/ci_tester/py.typed | 0 src/ci_tester/skeleton.py | 15 ++++++++------- tox.ini | 12 ++++++++++++ 6 files changed, 47 insertions(+), 9 deletions(-) create mode 100644 src/ci_tester/py.typed diff --git a/.cirrus.yml b/.cirrus.yml index 781c83d..01d5d68 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -179,3 +179,17 @@ coverage_task: - python --version - pre-commit --version - cat .pre-commit-config.yaml + + +typecheck_task: + name: typecheck (Linux - 3.9) + 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 diff --git a/setup.cfg b/setup.cfg index 4da1221..e1cf80b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -118,11 +118,22 @@ 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 + [pyscaffold] # PyScaffold's parameters when the project was created. # This will be used when updating. Do not change! -version = 4.1rc1.post1.dev1+gd709939 +version = 4.1rc1.post1.dev12+g76b5b80 package = ci_tester extensions = cirrus pre_commit + typed +typed = True diff --git a/setup.py b/setup.py index b11612c..c2ed95e 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ Setup file for ci-tester. Use setup.cfg to configure your project. - This file was generated with PyScaffold 4.1rc1.post1.dev1+gd709939. + This file was generated with PyScaffold 4.1rc1.post1.dev12+g76b5b80. PyScaffold helps you to put up the scaffold of your new Python project. Learn more under: https://pyscaffold.org/ """ diff --git a/src/ci_tester/py.typed b/src/ci_tester/py.typed new file mode 100644 index 0000000..e69de29 diff --git a/src/ci_tester/skeleton.py b/src/ci_tester/skeleton.py index 020fda2..eba3f97 100644 --- a/src/ci_tester/skeleton.py +++ b/src/ci_tester/skeleton.py @@ -23,6 +23,7 @@ import argparse import logging import sys +from typing import List from ci_tester import __version__ @@ -40,7 +41,7 @@ # when using this Python module as a library. -def fib(n): +def fib(n: int) -> int: """Fibonacci example function Args: @@ -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: @@ -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: @@ -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 @@ -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") diff --git a/tox.ini b/tox.ini index fe005ad..40aae2b 100644 --- a/tox.ini +++ b/tox.ini @@ -70,3 +70,15 @@ deps = twine commands = python -m twine check dist/* python -m twine upload {posargs:--repository testpypi} dist/* + + +[testenv:typecheck] +description = invoke mypy to typecheck the source code +changedir = {toxinidir} +passenv = + TERM + # ^ ensure colors +deps = + mypy +commands = + python -m mypy {posargs:src} From 82101f7e48858622e5c8dcfab4e882b01d51153b Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Sun, 12 Sep 2021 11:31:55 +0100 Subject: [PATCH 3/3] Add latest changes from pr493 --- .cirrus.yml | 30 ++++++++++++++++-------------- setup.cfg | 4 +++- setup.py | 2 +- src/ci_tester/skeleton.py | 2 +- tox.ini | 24 ++++++++++++------------ 5 files changed, 33 insertions(+), 29 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 01d5d68..281a022 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -10,6 +10,7 @@ env: # 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 @@ -56,6 +57,21 @@ env: # ---- 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 @@ -179,17 +195,3 @@ coverage_task: - python --version - pre-commit --version - cat .pre-commit-config.yaml - - -typecheck_task: - name: typecheck (Linux - 3.9) - 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 diff --git a/setup.cfg b/setup.cfg index e1cf80b..93a8f7e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -126,11 +126,13 @@ 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.1rc1.post1.dev12+g76b5b80 +version = 4.1rc1.post1.dev18+g423b773 package = ci_tester extensions = cirrus diff --git a/setup.py b/setup.py index c2ed95e..87fa59b 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ Setup file for ci-tester. Use setup.cfg to configure your project. - This file was generated with PyScaffold 4.1rc1.post1.dev12+g76b5b80. + 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/ """ diff --git a/src/ci_tester/skeleton.py b/src/ci_tester/skeleton.py index eba3f97..9ec07f9 100644 --- a/src/ci_tester/skeleton.py +++ b/src/ci_tester/skeleton.py @@ -23,7 +23,7 @@ import argparse import logging import sys -from typing import List +from typing import List # required for Python < 3.9 from ci_tester import __version__ diff --git a/tox.ini b/tox.ini index 40aae2b..1ff644f 100644 --- a/tox.ini +++ b/tox.ini @@ -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 @@ -70,15 +82,3 @@ deps = twine commands = python -m twine check dist/* python -m twine upload {posargs:--repository testpypi} dist/* - - -[testenv:typecheck] -description = invoke mypy to typecheck the source code -changedir = {toxinidir} -passenv = - TERM - # ^ ensure colors -deps = - mypy -commands = - python -m mypy {posargs:src}