From b5c4d17ba6f9e678f98ccfc1114eec4238cd7a77 Mon Sep 17 00:00:00 2001 From: Matt Wilson <152443343+mwsis@users.noreply.github.com> Date: Sun, 24 Aug 2025 12:44:45 +1000 Subject: [PATCH 1/2] Boilerplate, badges, compatibility claims (#17) * badges * * Python version compatibility claims; * badges; * boilerplate; --- CHANGES.md | 7 +++++++ README.md | 6 ++++++ diagnosticism/__init__.py | 2 +- setup.py | 8 +++++++- 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index d193f0e..c6f1867 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,12 @@ # **Diagnosticism.Python** Changes +## 0.15.1 - 24th August 2025 + +* Python version compatibility claims; +* badges; +* boilerplate; + + ## 0.15.0 - 13th August 2025 * added `asynctracefunc` decorator; diff --git a/README.md b/README.md index a27e9d1..c8ac61b 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,13 @@ Diagnosticism library, for Python + +[![License](https://img.shields.io/badge/License-BSD_3--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause) [![PyPI version](https://badge.fury.io/py/diagnosticism.svg)](https://badge.fury.io/py/diagnosticism) +![versions](https://img.shields.io/pypi/pyversions/diagnosticism.svg) +[![Last Commit](https://img.shields.io/github/last-commit/synesissoftware/Diagnosticism.Python)](https://github.com/synesissoftware/Diagnosticism.Python/commits/master) ## Table of Contents diff --git a/diagnosticism/__init__.py b/diagnosticism/__init__.py index 4fd92d5..3f13475 100644 --- a/diagnosticism/__init__.py +++ b/diagnosticism/__init__.py @@ -9,7 +9,7 @@ __license__ = 'BSD-3-Clause' __maintainer__ = 'Matt Wilson' __status__ = 'Beta' -__version__ = '0.15.0' +__version__ = '0.15.1' from .contingent_reporting import ( abort, diff --git a/setup.py b/setup.py index 607292a..4dd1748 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ setuptools.setup( name='diagnosticism', - version='0.15.0', + version='0.15.1', author='Matt Wilson', author_email='matthew@synesis.com.au', @@ -17,6 +17,12 @@ "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 3", + "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 :: 3.13", ], description='Basic diagnostic facilities, for Python', keywords='Diagnostic Diagnostics Logging Trace Tracing Stopwatch', From f9d627cc41228ca4fd4a8afb8d6c9349fd026eb3 Mon Sep 17 00:00:00 2001 From: Matt Wilson <152443343+mwsis@users.noreply.github.com> Date: Sun, 24 Aug 2025 13:15:35 +1000 Subject: [PATCH 2/2] GitHub Actions (#18) * * GitHub Actions; * branches * warning suppression * Python 3.8 compatibility * badges --- .github/workflows/python-package.yml | 43 ++++++++++++++++++++++++++++ CHANGES.md | 2 ++ README.md | 1 + diagnosticism/__init__.py | 10 +++++-- diagnosticism/severity.py | 2 +- tests/test_trace.py | 39 ++++++++++++++++--------- 6 files changed, 80 insertions(+), 17 deletions(-) create mode 100644 .github/workflows/python-package.yml diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml new file mode 100644 index 0000000..98ab029 --- /dev/null +++ b/.github/workflows/python-package.yml @@ -0,0 +1,43 @@ +# This workflow will install Python dependencies, run tests and lint with a variety of Python versions +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python + +name: Python package + +on: + push: + branches: [ "master", "dev", "gha" ] + pull_request: + branches: [ "master", "dev", "gha" ] + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] + + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install flake8 pytest + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Test with unittest + run: | + python3 -m unittest discover + - name: Test with pytest + run: | + pytest diff --git a/CHANGES.md b/CHANGES.md index c6f1867..13a25b2 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,6 +3,8 @@ ## 0.15.1 - 24th August 2025 * Python version compatibility claims; +* Python 3.8 compatibility; +* GitHub Actions; * badges; * boilerplate; diff --git a/README.md b/README.md index c8ac61b..1fb4bc3 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ Diagnosticism library, for Python [![License](https://img.shields.io/badge/License-BSD_3--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause) [![PyPI version](https://badge.fury.io/py/diagnosticism.svg)](https://badge.fury.io/py/diagnosticism) ![versions](https://img.shields.io/pypi/pyversions/diagnosticism.svg) +[![Python](https://github.com/synesissoftware/Diagnosticism.Python/actions/workflows/python-package.yml/badge.svg)](https://github.com/synesissoftware/Diagnosticism.Python/actions/workflows/python-package.yml) [![Last Commit](https://img.shields.io/github/last-commit/synesissoftware/Diagnosticism.Python)](https://github.com/synesissoftware/Diagnosticism.Python/commits/master) diff --git a/diagnosticism/__init__.py b/diagnosticism/__init__.py index 3f13475..1e5febc 100644 --- a/diagnosticism/__init__.py +++ b/diagnosticism/__init__.py @@ -11,6 +11,8 @@ __status__ = 'Beta' __version__ = '0.15.1' +import sys + from .contingent_reporting import ( abort, report, @@ -39,9 +41,13 @@ is_tracing_enabled, line, trace, - tracefunc, - asynctracefunc, ) +if sys.version_info[:2] >= (3, 9): + from .tracing import ( + tracefunc, + asynctracefunc, + ) + from .warning import warn diff --git a/diagnosticism/severity.py b/diagnosticism/severity.py index bb05e5e..9824b3d 100644 --- a/diagnosticism/severity.py +++ b/diagnosticism/severity.py @@ -115,7 +115,7 @@ _INTEGER_TYPES = (int, ) else: - _INTEGER_TYPES = (int, long, ) + _INTEGER_TYPES = (int, long, ) # noqa: F821 def _parse_verbosity( diff --git a/tests/test_trace.py b/tests/test_trace.py index 726f27b..94eb922 100755 --- a/tests/test_trace.py +++ b/tests/test_trace.py @@ -4,8 +4,12 @@ from diagnosticism.tracing import ( enable_tracing, trace, - tracefunc, ) +import sys +if sys.version_info[:2] >= (3, 9): + from diagnosticism.tracing import ( + tracefunc, + ) import unittest from unittest.mock import patch @@ -28,11 +32,17 @@ def f1(): return "f1-result" -@tracefunc -def f2(): +if sys.version_info[:2] >= (3, 9): - return "f2-result" + @tracefunc + def f2(): + return "f2-result" +else: + + def f2(): + + pass class Trace_tester(unittest.TestCase): @@ -89,20 +99,21 @@ def test__trace__WITH_TRACING_ENABLED(self): enable_tracing(tracing_enabled) - def test__tracefunc__WITH_TRACING_ENABLED(self): + if sys.version_info[:2] >= (3, 9): + def test__tracefunc__WITH_TRACING_ENABLED(self): - with patch('sys.stderr', new=StringIO()) as fake_stderr: + with patch('sys.stderr', new=StringIO()) as fake_stderr: - tracing_enabled = True if enable_tracing(True) else False + tracing_enabled = True if enable_tracing(True) else False - try: + try: - set_program_name('myprog3') + set_program_name('myprog3') - r = f2() + r = f2() - self.assertEqual('f2-result', r) - self.assertRegex(fake_stderr.getvalue(), r'^\[myprog3, \d+, \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{6}, .*TRACE.*\]: f2()') - finally: + self.assertEqual('f2-result', r) + self.assertRegex(fake_stderr.getvalue(), r'^\[myprog3, \d+, \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{6}, .*TRACE.*\]: f2()') + finally: - enable_tracing(tracing_enabled) + enable_tracing(tracing_enabled)