From 335a4de6fce95acf5e5c81bcf6b1c3f24b512073 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ionel=20Cristian=20M=C4=83rie=C8=99?= Date: Sat, 23 Mar 2024 17:22:17 +0200 Subject: [PATCH] Up. --- .bumpversion.cfg | 16 +- .cookiecutterrc | 8 +- .coveragerc | 6 +- .github/workflows/github-actions.yml | 276 +++++------------- .gitignore | 58 ++-- .pre-commit-config.yaml | 8 +- .readthedocs.yml | 4 + CHANGELOG.rst | 2 +- CONTRIBUTING.rst | 2 +- README.rst | 15 +- ci/bootstrap.py | 3 +- .../.github/workflows/github-actions.yml | 18 +- docs/conf.py | 9 +- docs/reference/nameless.rst | 2 + docs/requirements.txt | 2 +- pyproject.toml | 23 +- pytest.ini | 19 +- setup.py | 6 +- src/nameless/__init__.py | 6 + src/nameless/__main__.py | 5 +- src/nameless/cli.py | 7 +- src/nameless/core.py | 2 + src/nameless/tests/__init__.py | 0 src/nameless/tests/test_cli.py | 5 + src/nameless/tests/test_core.py | 5 + tests/test_nameless.py | 11 - tox.ini | 31 +- 27 files changed, 211 insertions(+), 338 deletions(-) create mode 100644 src/nameless/core.py create mode 100644 src/nameless/tests/__init__.py create mode 100644 src/nameless/tests/test_cli.py create mode 100644 src/nameless/tests/test_core.py delete mode 100644 tests/test_nameless.py diff --git a/.bumpversion.cfg b/.bumpversion.cfg index fcb0791be..b3e0bf322 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -4,8 +4,8 @@ commit = True tag = True [bumpversion:file:setup.py] -search = version='{current_version}' -replace = version='{new_version}' +search = version="{current_version}" +replace = version="{new_version}" [bumpversion:file (badge):README.rst] search = /v{current_version}.svg @@ -16,9 +16,13 @@ search = /v{current_version}...main replace = /v{new_version}...main [bumpversion:file:docs/conf.py] -search = version = release = '{current_version}' -replace = version = release = '{new_version}' +search = version = release = "{current_version}" +replace = version = release = "{new_version}" [bumpversion:file:src/nameless/__init__.py] -search = __version__ = '{current_version}' -replace = __version__ = '{new_version}' +search = __version__ = "{current_version}" +replace = __version__ = "{new_version}" + +[bumpversion:file:.cookiecutterrc] +search = version: {current_version} +replace = version: {new_version} diff --git a/.cookiecutterrc b/.cookiecutterrc index fb9abab7a..23f5bc9d5 100644 --- a/.cookiecutterrc +++ b/.cookiecutterrc @@ -1,8 +1,6 @@ # Generated by cookiepatcher, a small shim around cookiecutter (pip install cookiepatcher) default_context: - allow_tests_inside_package: 'no' - c_extension_function: longest c_extension_module: _nameless c_extension_optional: 'yes' c_extension_support: 'no' @@ -21,6 +19,7 @@ default_context: github_actions_osx: 'yes' github_actions_windows: 'yes' license: BSD 2-Clause License + module_name: core package_name: nameless pre_commit: 'yes' project_name: Nameless @@ -38,8 +37,9 @@ default_context: sphinx_docs: 'yes' sphinx_docs_hosting: https://python-nameless.readthedocs.io/ sphinx_doctest: 'yes' - sphinx_theme: sphinx-rtd-theme - test_matrix_separate_coverage: 'yes' + sphinx_theme: furo + test_matrix_separate_coverage: 'no' + tests_inside_package: 'yes' version: 0.1.0 version_manager: bump2version website: https://blog.ionelmc.ro diff --git a/.coveragerc b/.coveragerc index 770e36ed7..03daa1563 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,10 +1,12 @@ [paths] -source = src +source = + src + */site-packages [run] branch = true source = - src + nameless tests parallel = true diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml index 897ddcb8f..41d952a30 100644 --- a/.github/workflows/github-actions.yml +++ b/.github/workflows/github-actions.yml @@ -19,299 +19,155 @@ jobs: toxpython: 'python3.11' tox_env: 'docs' os: 'ubuntu-latest' - - name: 'py37-cover (ubuntu)' - python: '3.7' - toxpython: 'python3.7' - python_arch: 'x64' - tox_env: 'py37-cover,codecov' - os: 'ubuntu-latest' - - name: 'py37-cover (windows)' - python: '3.7' - toxpython: 'python3.7' - python_arch: 'x64' - tox_env: 'py37-cover,codecov' - os: 'windows-latest' - - name: 'py37-cover (macos)' - python: '3.7' - toxpython: 'python3.7' - python_arch: 'x64' - tox_env: 'py37-cover,codecov' - os: 'macos-latest' - - name: 'py37-nocov (ubuntu)' - python: '3.7' - toxpython: 'python3.7' - python_arch: 'x64' - tox_env: 'py37-nocov' - os: 'ubuntu-latest' - - name: 'py37-nocov (windows)' - python: '3.7' - toxpython: 'python3.7' - python_arch: 'x64' - tox_env: 'py37-nocov' - os: 'windows-latest' - - name: 'py37-nocov (macos)' - python: '3.7' - toxpython: 'python3.7' - python_arch: 'x64' - tox_env: 'py37-nocov' - os: 'macos-latest' - - name: 'py38-cover (ubuntu)' + - name: 'py38 (ubuntu)' python: '3.8' toxpython: 'python3.8' python_arch: 'x64' - tox_env: 'py38-cover,codecov' + tox_env: 'py38' os: 'ubuntu-latest' - - name: 'py38-cover (windows)' + - name: 'py38 (windows)' python: '3.8' toxpython: 'python3.8' python_arch: 'x64' - tox_env: 'py38-cover,codecov' + tox_env: 'py38' os: 'windows-latest' - - name: 'py38-cover (macos)' + - name: 'py38 (macos)' python: '3.8' toxpython: 'python3.8' python_arch: 'x64' - tox_env: 'py38-cover,codecov' + tox_env: 'py38' os: 'macos-latest' - - name: 'py38-nocov (ubuntu)' - python: '3.8' - toxpython: 'python3.8' - python_arch: 'x64' - tox_env: 'py38-nocov' - os: 'ubuntu-latest' - - name: 'py38-nocov (windows)' - python: '3.8' - toxpython: 'python3.8' - python_arch: 'x64' - tox_env: 'py38-nocov' - os: 'windows-latest' - - name: 'py38-nocov (macos)' - python: '3.8' - toxpython: 'python3.8' - python_arch: 'x64' - tox_env: 'py38-nocov' - os: 'macos-latest' - - name: 'py39-cover (ubuntu)' + - name: 'py39 (ubuntu)' python: '3.9' toxpython: 'python3.9' python_arch: 'x64' - tox_env: 'py39-cover,codecov' + tox_env: 'py39' os: 'ubuntu-latest' - - name: 'py39-cover (windows)' + - name: 'py39 (windows)' python: '3.9' toxpython: 'python3.9' python_arch: 'x64' - tox_env: 'py39-cover,codecov' + tox_env: 'py39' os: 'windows-latest' - - name: 'py39-cover (macos)' - python: '3.9' - toxpython: 'python3.9' - python_arch: 'x64' - tox_env: 'py39-cover,codecov' - os: 'macos-latest' - - name: 'py39-nocov (ubuntu)' + - name: 'py39 (macos)' python: '3.9' toxpython: 'python3.9' python_arch: 'x64' - tox_env: 'py39-nocov' - os: 'ubuntu-latest' - - name: 'py39-nocov (windows)' - python: '3.9' - toxpython: 'python3.9' - python_arch: 'x64' - tox_env: 'py39-nocov' - os: 'windows-latest' - - name: 'py39-nocov (macos)' - python: '3.9' - toxpython: 'python3.9' - python_arch: 'x64' - tox_env: 'py39-nocov' - os: 'macos-latest' - - name: 'py310-cover (ubuntu)' - python: '3.10' - toxpython: 'python3.10' - python_arch: 'x64' - tox_env: 'py310-cover,codecov' - os: 'ubuntu-latest' - - name: 'py310-cover (windows)' - python: '3.10' - toxpython: 'python3.10' - python_arch: 'x64' - tox_env: 'py310-cover,codecov' - os: 'windows-latest' - - name: 'py310-cover (macos)' - python: '3.10' - toxpython: 'python3.10' - python_arch: 'x64' - tox_env: 'py310-cover,codecov' + tox_env: 'py39' os: 'macos-latest' - - name: 'py310-nocov (ubuntu)' + - name: 'py310 (ubuntu)' python: '3.10' toxpython: 'python3.10' python_arch: 'x64' - tox_env: 'py310-nocov' + tox_env: 'py310' os: 'ubuntu-latest' - - name: 'py310-nocov (windows)' + - name: 'py310 (windows)' python: '3.10' toxpython: 'python3.10' python_arch: 'x64' - tox_env: 'py310-nocov' + tox_env: 'py310' os: 'windows-latest' - - name: 'py310-nocov (macos)' + - name: 'py310 (macos)' python: '3.10' toxpython: 'python3.10' python_arch: 'x64' - tox_env: 'py310-nocov' - os: 'macos-latest' - - name: 'py311-cover (ubuntu)' - python: '3.11' - toxpython: 'python3.11' - python_arch: 'x64' - tox_env: 'py311-cover,codecov' - os: 'ubuntu-latest' - - name: 'py311-cover (windows)' - python: '3.11' - toxpython: 'python3.11' - python_arch: 'x64' - tox_env: 'py311-cover,codecov' - os: 'windows-latest' - - name: 'py311-cover (macos)' - python: '3.11' - toxpython: 'python3.11' - python_arch: 'x64' - tox_env: 'py311-cover,codecov' + tox_env: 'py310' os: 'macos-latest' - - name: 'py311-nocov (ubuntu)' + - name: 'py311 (ubuntu)' python: '3.11' toxpython: 'python3.11' python_arch: 'x64' - tox_env: 'py311-nocov' + tox_env: 'py311' os: 'ubuntu-latest' - - name: 'py311-nocov (windows)' + - name: 'py311 (windows)' python: '3.11' toxpython: 'python3.11' python_arch: 'x64' - tox_env: 'py311-nocov' + tox_env: 'py311' os: 'windows-latest' - - name: 'py311-nocov (macos)' + - name: 'py311 (macos)' python: '3.11' toxpython: 'python3.11' python_arch: 'x64' - tox_env: 'py311-nocov' + tox_env: 'py311' os: 'macos-latest' - - name: 'pypy37-cover (ubuntu)' - python: 'pypy-3.7' - toxpython: 'pypy3.7' + - name: 'py312 (ubuntu)' + python: '3.12' + toxpython: 'python3.12' python_arch: 'x64' - tox_env: 'pypy37-cover,codecov' + tox_env: 'py312' os: 'ubuntu-latest' - - name: 'pypy37-cover (windows)' - python: 'pypy-3.7' - toxpython: 'pypy3.7' + - name: 'py312 (windows)' + python: '3.12' + toxpython: 'python3.12' python_arch: 'x64' - tox_env: 'pypy37-cover,codecov' + tox_env: 'py312' os: 'windows-latest' - - name: 'pypy37-cover (macos)' - python: 'pypy-3.7' - toxpython: 'pypy3.7' + - name: 'py312 (macos)' + python: '3.12' + toxpython: 'python3.12' python_arch: 'x64' - tox_env: 'pypy37-cover,codecov' + tox_env: 'py312' os: 'macos-latest' - - name: 'pypy37-nocov (ubuntu)' - python: 'pypy-3.7' - toxpython: 'pypy3.7' - python_arch: 'x64' - tox_env: 'pypy37-nocov' - os: 'ubuntu-latest' - - name: 'pypy37-nocov (windows)' - python: 'pypy-3.7' - toxpython: 'pypy3.7' - python_arch: 'x64' - tox_env: 'pypy37-nocov' - os: 'windows-latest' - - name: 'pypy37-nocov (macos)' - python: 'pypy-3.7' - toxpython: 'pypy3.7' - python_arch: 'x64' - tox_env: 'pypy37-nocov' - os: 'macos-latest' - - name: 'pypy38-cover (ubuntu)' + - name: 'pypy38 (ubuntu)' python: 'pypy-3.8' toxpython: 'pypy3.8' python_arch: 'x64' - tox_env: 'pypy38-cover,codecov' + tox_env: 'pypy38' os: 'ubuntu-latest' - - name: 'pypy38-cover (windows)' + - name: 'pypy38 (windows)' python: 'pypy-3.8' toxpython: 'pypy3.8' python_arch: 'x64' - tox_env: 'pypy38-cover,codecov' + tox_env: 'pypy38' os: 'windows-latest' - - name: 'pypy38-cover (macos)' + - name: 'pypy38 (macos)' python: 'pypy-3.8' toxpython: 'pypy3.8' python_arch: 'x64' - tox_env: 'pypy38-cover,codecov' + tox_env: 'pypy38' os: 'macos-latest' - - name: 'pypy38-nocov (ubuntu)' - python: 'pypy-3.8' - toxpython: 'pypy3.8' - python_arch: 'x64' - tox_env: 'pypy38-nocov' - os: 'ubuntu-latest' - - name: 'pypy38-nocov (windows)' - python: 'pypy-3.8' - toxpython: 'pypy3.8' - python_arch: 'x64' - tox_env: 'pypy38-nocov' - os: 'windows-latest' - - name: 'pypy38-nocov (macos)' - python: 'pypy-3.8' - toxpython: 'pypy3.8' - python_arch: 'x64' - tox_env: 'pypy38-nocov' - os: 'macos-latest' - - name: 'pypy39-cover (ubuntu)' + - name: 'pypy39 (ubuntu)' python: 'pypy-3.9' toxpython: 'pypy3.9' python_arch: 'x64' - tox_env: 'pypy39-cover,codecov' + tox_env: 'pypy39' os: 'ubuntu-latest' - - name: 'pypy39-cover (windows)' + - name: 'pypy39 (windows)' python: 'pypy-3.9' toxpython: 'pypy3.9' python_arch: 'x64' - tox_env: 'pypy39-cover,codecov' + tox_env: 'pypy39' os: 'windows-latest' - - name: 'pypy39-cover (macos)' + - name: 'pypy39 (macos)' python: 'pypy-3.9' toxpython: 'pypy3.9' python_arch: 'x64' - tox_env: 'pypy39-cover,codecov' + tox_env: 'pypy39' os: 'macos-latest' - - name: 'pypy39-nocov (ubuntu)' - python: 'pypy-3.9' - toxpython: 'pypy3.9' + - name: 'pypy310 (ubuntu)' + python: 'pypy-3.10' + toxpython: 'pypy3.10' python_arch: 'x64' - tox_env: 'pypy39-nocov' + tox_env: 'pypy310' os: 'ubuntu-latest' - - name: 'pypy39-nocov (windows)' - python: 'pypy-3.9' - toxpython: 'pypy3.9' + - name: 'pypy310 (windows)' + python: 'pypy-3.10' + toxpython: 'pypy3.10' python_arch: 'x64' - tox_env: 'pypy39-nocov' + tox_env: 'pypy310' os: 'windows-latest' - - name: 'pypy39-nocov (macos)' - python: 'pypy-3.9' - toxpython: 'pypy3.9' + - name: 'pypy310 (macos)' + python: 'pypy-3.10' + toxpython: 'pypy3.10' python_arch: 'x64' - tox_env: 'pypy39-nocov' + tox_env: 'pypy310' os: 'macos-latest' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python }} architecture: ${{ matrix.python_arch }} @@ -327,3 +183,11 @@ jobs: TOXPYTHON: '${{ matrix.toxpython }}' run: > tox -e ${{ matrix.tox_env }} -v + finish: + needs: test + if: ${{ always() }} + runs-on: ubuntu-latest + steps: + - uses: coverallsapp/github-action@v2 + with: + parallel-finished: true diff --git a/.gitignore b/.gitignore index 83a43fdbd..77973dd9f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,40 +1,53 @@ *.py[cod] __pycache__ +# Temp files +.*.sw[po] +*~ +*.bak +.DS_Store + # C extensions *.so -# Packages +# Build and package files *.egg *.egg-info -dist -build -eggs +.bootstrap +.build +.cache .eggs -parts +.env +.installed.cfg +.ve bin -var -sdist -wheelhouse +build develop-eggs -.installed.cfg +dist +eggs lib lib64 -venv*/ -pyvenv*/ +parts pip-wheel-metadata/ +pyvenv*/ +sdist +var +venv*/ +wheelhouse # Installer logs pip-log.txt # Unit test / coverage reports +.benchmarks .coverage -.tox .coverage.* +.pytest .pytest_cache/ -nosetests.xml +.tox coverage.xml htmlcov +nosetests.xml # Translations *.mo @@ -43,12 +56,12 @@ htmlcov .mr.developer.cfg # IDE project files +*.iml +*.komodoproject +.idea .project .pydevproject -.idea .vscode -*.iml -*.komodoproject # Complexity output/*.html @@ -57,18 +70,5 @@ output/*/index.html # Sphinx docs/_build -.DS_Store -*~ -.*.sw[po] -.build -.ve -.env -.cache -.pytest -.benchmarks -.bootstrap -.appveyor.token -*.bak - # Mypy Cache .mypy_cache/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f1b7b5ae8..ff3e46436 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,17 +5,17 @@ exclude: '^(\.tox|ci/templates|\.bumpversion\.cfg)(/|$)' # Note the order is intentional to avoid multiple passes of the hooks repos: - - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.0.262 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.3.4 hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix, --show-fixes] - repo: https://github.com/psf/black - rev: 23.3.0 + rev: 24.3.0 hooks: - id: black - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.5.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer diff --git a/.readthedocs.yml b/.readthedocs.yml index 59ff5c04f..009a913cd 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -3,6 +3,10 @@ version: 2 sphinx: configuration: docs/conf.py formats: all +build: + os: ubuntu-22.04 + tools: + python: "3" python: install: - requirements: docs/requirements.txt diff --git a/CHANGELOG.rst b/CHANGELOG.rst index c70bf41f7..62d259798 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,7 +2,7 @@ Changelog ========= -0.1.0 (2023-04-23) +0.1.0 (2024-03-23) ------------------ * First release on PyPI. diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 7685aa5e5..bc167684f 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -49,7 +49,7 @@ To set up `python-nameless` for local development: Now you can make your changes locally. -4. When you're done making changes run all the checks and docs builder with `tox `_ one command:: +4. When you're done making changes run all the checks and docs builder with one command:: tox diff --git a/README.rst b/README.rst index b9aad25cd..c61f11b49 100644 --- a/README.rst +++ b/README.rst @@ -10,27 +10,24 @@ Overview * - docs - |docs| * - tests - - | |github-actions| - | |coveralls| |codecov| - | |scrutinizer| |codeclimate| + - |github-actions| |coveralls| |codecov| |scrutinizer| |codeclimate| * - package - - | |version| |wheel| |supported-versions| |supported-implementations| - | |commits-since| + - |version| |wheel| |supported-versions| |supported-implementations| |commits-since| .. |docs| image:: https://readthedocs.org/projects/python-nameless/badge/?style=flat - :target: https://python-nameless.readthedocs.io/ + :target: https://readthedocs.org/projects/python-nameless/ :alt: Documentation Status .. |github-actions| image:: https://github.com/ionelmc/python-nameless/actions/workflows/github-actions.yml/badge.svg :alt: GitHub Actions Build Status :target: https://github.com/ionelmc/python-nameless/actions -.. |coveralls| image:: https://coveralls.io/repos/ionelmc/python-nameless/badge.svg?branch=main&service=github +.. |coveralls| image:: https://coveralls.io/repos/github/ionelmc/python-nameless/badge.svg?branch=main :alt: Coverage Status - :target: https://coveralls.io/r/ionelmc/python-nameless + :target: https://coveralls.io/github/ionelmc/python-nameless?branch=main .. |codecov| image:: https://codecov.io/gh/ionelmc/python-nameless/branch/main/graphs/badge.svg?branch=main :alt: Coverage Status - :target: https://codecov.io/github/ionelmc/python-nameless + :target: https://app.codecov.io/github/ionelmc/python-nameless .. |codeclimate| image:: https://codeclimate.com/github/ionelmc/python-nameless/badges/gpa.svg :target: https://codeclimate.com/github/ionelmc/python-nameless diff --git a/ci/bootstrap.py b/ci/bootstrap.py index 7bb9d826b..6b72c2fa4 100755 --- a/ci/bootstrap.py +++ b/ci/bootstrap.py @@ -1,5 +1,4 @@ #!/usr/bin/env python -# ruff: noqa: S import os import pathlib import subprocess @@ -65,7 +64,7 @@ def main(): tox_environments = [line for line in tox_environments if line.startswith("py")] for template in templates_path.rglob("*"): if template.is_file(): - template_path = str(template.relative_to(templates_path)) + template_path = template.relative_to(templates_path).as_posix() destination = base_path / template_path destination.parent.mkdir(parents=True, exist_ok=True) destination.write_text(jinja.get_template(template_path).render(tox_environments=tox_environments)) diff --git a/ci/templates/.github/workflows/github-actions.yml b/ci/templates/.github/workflows/github-actions.yml index b73a6c14c..4469b9e9f 100644 --- a/ci/templates/.github/workflows/github-actions.yml +++ b/ci/templates/.github/workflows/github-actions.yml @@ -22,9 +22,9 @@ jobs: {% for env in tox_environments %} {% set prefix = env.split('-')[0] -%} {% if prefix.startswith('pypy') %} -{% set python %}pypy-{{ prefix[4] }}.{{ prefix[5] }}{% endset %} +{% set python %}pypy-{{ prefix[4] }}.{{ prefix[5:] }}{% endset %} {% set cpython %}pp{{ prefix[4:5] }}{% endset %} -{% set toxpython %}pypy{{ prefix[4] }}.{{ prefix[5] }}{% endset %} +{% set toxpython %}pypy{{ prefix[4] }}.{{ prefix[5:] }}{% endset %} {% else %} {% set python %}{{ prefix[2] }}.{{ prefix[3:] }}{% endset %} {% set cpython %}cp{{ prefix[2:] }}{% endset %} @@ -39,15 +39,15 @@ jobs: python: '{{ python }}' toxpython: '{{ toxpython }}' python_arch: '{{ python_arch }}' - tox_env: '{{ env }}{% if 'cover' in env %},codecov{% endif %}' + tox_env: '{{ env }}' os: '{{ os }}-latest' {% endfor %} {% endfor %} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version: {{ '${{ matrix.python }}' }} architecture: {{ '${{ matrix.python_arch }}' }} @@ -63,3 +63,11 @@ jobs: TOXPYTHON: '{{ '${{ matrix.toxpython }}' }}' run: > tox -e {{ '${{ matrix.tox_env }}' }} -v + finish: + needs: test + if: {{ '${{ always() }}' }} + runs-on: ubuntu-latest + steps: + - uses: coverallsapp/github-action@v2 + with: + parallel-finished: true diff --git a/docs/conf.py b/docs/conf.py index 1989ac4c5..d75ddb1fa 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,5 +1,3 @@ -import os - extensions = [ "sphinx.ext.autodoc", "sphinx.ext.autosummary", @@ -25,11 +23,10 @@ "issue": ("https://github.com/ionelmc/python-nameless/issues/%s", "#"), "pr": ("https://github.com/ionelmc/python-nameless/pull/%s", "PR #"), } -# on_rtd is whether we are on readthedocs.org -on_rtd = os.environ.get("READTHEDOCS", None) == "True" -if not on_rtd: # only set the theme if we are building docs locally - html_theme = "sphinx_rtd_theme" +html_theme_options = { + "githuburl": "https://github.com/ionelmc/python-nameless/", +} html_use_smartypants = True html_last_updated_fmt = "%b %d, %Y" diff --git a/docs/reference/nameless.rst b/docs/reference/nameless.rst index feaaa1c35..6ca562799 100644 --- a/docs/reference/nameless.rst +++ b/docs/reference/nameless.rst @@ -7,3 +7,5 @@ nameless .. automodule:: nameless :members: + :undoc-members: + :special-members: __init__, __len__ diff --git a/docs/requirements.txt b/docs/requirements.txt index 37da9aeed..c03e307ab 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,2 +1,2 @@ sphinx>=1.3 -sphinx-rtd-theme +furo diff --git a/pyproject.toml b/pyproject.toml index d8ecbdce1..e191a8b40 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,21 +1,26 @@ [build-system] requires = [ "setuptools>=30.3.0", - "wheel", ] -[tool.ruff.per-file-ignores] -"ci/*" = ["S"] - [tool.ruff] extend-exclude = ["static", "ci/templates"] +line-length = 140 +src = ["src", "tests"] +target-version = "py38" + +[tool.ruff.lint.per-file-ignores] +"ci/*" = ["S"] + +[tool.ruff.lint] ignore = [ "RUF001", # ruff-specific rules ambiguous-unicode-character-string "S101", # flake8-bandit assert "S308", # flake8-bandit suspicious-mark-safe-usage + "S603", # flake8-bandit subprocess-without-shell-equals-true + "S607", # flake8-bandit start-process-with-partial-path "E501", # pycodestyle line-too-long ] -line-length = 140 select = [ "B", # flake8-bugbear "C4", # flake8-comprehensions @@ -37,17 +42,15 @@ select = [ "UP", # pyupgrade "W", # pycodestyle warnings ] -src = ["src", "tests"] -target-version = "py310" -[tool.ruff.flake8-pytest-style] +[tool.ruff.lint.flake8-pytest-style] fixture-parentheses = false mark-parentheses = false -[tool.ruff.isort] +[tool.ruff.lint.isort] forced-separate = ["conftest"] force-single-line = true [tool.black] line-length = 140 -target-version = ["py310"] +target-version = ["py38"] diff --git a/pytest.ini b/pytest.ini index 8838f3e6f..92c7c9e80 100644 --- a/pytest.ini +++ b/pytest.ini @@ -4,11 +4,6 @@ # so if you add a pytest config section elsewhere, # you will need to delete this section from setup.cfg. norecursedirs = - .git - .tox - .env - dist - build migrations python_files = @@ -18,15 +13,19 @@ python_files = addopts = -ra --strict-markers - --ignore=docs/conf.py - --ignore=setup.py - --ignore=ci - --ignore=.eggs --doctest-modules --doctest-glob=\*.rst --tb=short + --pyargs +# The order of these options matters. testpaths comes after addopts so that +# nameless in testpaths is interpreted as +# --pyargs nameless. +# Any tests in the src/ directory (that is, tests installed with the package) +# can be run by any user with pytest --pyargs nameless. testpaths = - tests + nameless +# If you want to switch back to tests outside package just remove --pyargs +# and edit testpaths to have "tests/" instead of "nameless". # Idea from: https://til.simonwillison.net/pytest/treat-warnings-as-errors filterwarnings = diff --git a/setup.py b/setup.py index 3712f1ace..717142ba7 100755 --- a/setup.py +++ b/setup.py @@ -39,11 +39,11 @@ def read(*names, **kwargs): "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3 :: Only", - "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", + "Programming Language :: Python :: 3.12", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", # uncomment if you test on these interpreters: @@ -60,7 +60,7 @@ def read(*names, **kwargs): keywords=[ # eg: "keyword1", "keyword2", "keyword3", ], - python_requires=">=3.7", + python_requires=">=3.8", install_requires=[ "click", # eg: "aspectlib==1.1.1", "six>=1.7", @@ -72,7 +72,7 @@ def read(*names, **kwargs): }, entry_points={ "console_scripts": [ - "nameless = nameless.cli:main", + "nameless = nameless.cli:run", ] }, ) diff --git a/src/nameless/__init__.py b/src/nameless/__init__.py index 3dc1f76bc..9553db54b 100644 --- a/src/nameless/__init__.py +++ b/src/nameless/__init__.py @@ -1 +1,7 @@ __version__ = "0.1.0" + +from .core import main + +__all__ = [ + "main", +] diff --git a/src/nameless/__main__.py b/src/nameless/__main__.py index 31b373fc2..1fb9bbcec 100644 --- a/src/nameless/__main__.py +++ b/src/nameless/__main__.py @@ -8,7 +8,8 @@ - https://docs.python.org/2/using/cmdline.html#cmdoption-m - https://docs.python.org/3/using/cmdline.html#cmdoption-m """ -from nameless.cli import main + +from nameless.cli import run if __name__ == "__main__": - main() + run() diff --git a/src/nameless/cli.py b/src/nameless/cli.py index f33153607..fd02a154a 100644 --- a/src/nameless/cli.py +++ b/src/nameless/cli.py @@ -14,10 +14,13 @@ Also see (1) from http://click.pocoo.org/5/setuptools/#setuptools-integration """ + import click +from .core import main + @click.command() @click.argument("names", nargs=-1) -def main(names): - click.echo(repr(names)) +def run(names): + click.echo(main(names)) diff --git a/src/nameless/core.py b/src/nameless/core.py new file mode 100644 index 000000000..b3d97ad08 --- /dev/null +++ b/src/nameless/core.py @@ -0,0 +1,2 @@ +def main(args): + return max(args, key=len) diff --git a/src/nameless/tests/__init__.py b/src/nameless/tests/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/src/nameless/tests/test_cli.py b/src/nameless/tests/test_cli.py new file mode 100644 index 000000000..ba64f5e7b --- /dev/null +++ b/src/nameless/tests/test_cli.py @@ -0,0 +1,5 @@ +import subprocess + + +def test_main(): + assert subprocess.check_output(["nameless", "foo", "foobar"], text=True) == "foobar\n" diff --git a/src/nameless/tests/test_core.py b/src/nameless/tests/test_core.py new file mode 100644 index 000000000..caa17d1b1 --- /dev/null +++ b/src/nameless/tests/test_core.py @@ -0,0 +1,5 @@ +from .. import main + + +def test_main(): + assert main([b"a", b"bc", b"abc"]) == b"abc" diff --git a/tests/test_nameless.py b/tests/test_nameless.py deleted file mode 100644 index 6149d64c8..000000000 --- a/tests/test_nameless.py +++ /dev/null @@ -1,11 +0,0 @@ -from click.testing import CliRunner - -from nameless.cli import main - - -def test_main(): - runner = CliRunner() - result = runner.invoke(main, []) - - assert result.output == "()\n" - assert result.exit_code == 0 diff --git a/tox.ini b/tox.ini index a22150684..6b7454a04 100644 --- a/tox.ini +++ b/tox.ini @@ -8,41 +8,38 @@ commands = passenv = * -; a generative tox configuration, see: https://tox.wiki/en/latest/config.html#generative-envlist +; a generative tox configuration, see: https://tox.wiki/en/latest/user_guide.html#generative-environments [tox] envlist = clean, check, docs, - {py37,py38,py39,py310,py311,pypy37,pypy38,pypy39}-{cover,nocov}, + {py38,py39,py310,py311,py312,pypy38,pypy39,pypy310}, report ignore_basepython_conflict = true [testenv] basepython = - pypy37: {env:TOXPYTHON:pypy3.7} pypy38: {env:TOXPYTHON:pypy3.8} pypy39: {env:TOXPYTHON:pypy3.9} - py37: {env:TOXPYTHON:python3.7} + pypy310: {env:TOXPYTHON:pypy3.10} py38: {env:TOXPYTHON:python3.8} py39: {env:TOXPYTHON:python3.9} py310: {env:TOXPYTHON:python3.10} py311: {env:TOXPYTHON:python3.11} + py312: {env:TOXPYTHON:python3.12} {bootstrap,clean,check,report,docs,codecov,coveralls}: {env:TOXPYTHON:python3} setenv = PYTHONPATH={toxinidir}/tests PYTHONUNBUFFERED=yes passenv = * -usedevelop = - cover: true - nocov: false +usedevelop = false deps = pytest - cover: pytest-cov + pytest-cov commands = - nocov: {posargs:pytest -vv --ignore=src} - cover: {posargs:pytest --cov --cov-report=term-missing -vv} + {posargs:pytest --cov --cov-report=term-missing --cov-report=xml -vv } [testenv:check] deps = @@ -67,20 +64,6 @@ commands = sphinx-build {posargs:-E} -b html docs dist/docs sphinx-build -b linkcheck docs dist/docs -[testenv:coveralls] -deps = - coveralls -skip_install = true -commands = - coveralls [] - -[testenv:codecov] -deps = - codecov -skip_install = true -commands = - codecov [] - [testenv:report] deps = coverage