From 981b0551a68c61122f26d067e07c1ec2d8d32184 Mon Sep 17 00:00:00 2001 From: cassirer-openai Date: Wed, 21 May 2025 21:27:03 -0700 Subject: [PATCH 1/8] Fix upper bound type error message --- spans/types.py | 2 +- tests/test_range.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/spans/types.py b/spans/types.py index d1aae1c..0a6c941 100644 --- a/spans/types.py +++ b/spans/types.py @@ -124,7 +124,7 @@ def __init__(self, lower=None, upper=None, lower_inc=None, upper_inc=None): if upper is not None and not isinstance(upper, self.type): raise TypeError( - f"Invalid type for lower bound '{upper.__class__.__name__}'" + f"Invalid type for upper bound '{upper.__class__.__name__}'" f" expected '{self.type.__name__}'" ) diff --git a/tests/test_range.py b/tests/test_range.py index 41d590d..58df184 100644 --- a/tests/test_range.py +++ b/tests/test_range.py @@ -66,6 +66,11 @@ def test_invalid_construction(range_type, lower, upper, lower_inc, upper_inc, ex range_type(lower, upper, lower_inc, upper_inc) +def test_invalid_upper_bound_message(): + with pytest.raises(TypeError, match="upper bound"): + intrange(1, 1.5) + + @pytest.mark.parametrize( "range_type, lower, upper", [ From 953a67976e05e2410561c7e2f14b417977e08f33 Mon Sep 17 00:00:00 2001 From: cassirer-openai Date: Wed, 21 May 2025 21:32:43 -0700 Subject: [PATCH 2/8] Fix typos in module docstring --- spans/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spans/__init__.py b/spans/__init__.py index 588d786..666dbca 100644 --- a/spans/__init__.py +++ b/spans/__init__.py @@ -2,12 +2,12 @@ This module provides one dimensional continuous set support for python. Python has a wonderful set class, it does however not handle continuous sets -between two endpoints. This module tries to mitigate that. The ranges' behavoir +between two endpoints. This module tries to mitigate that. The ranges' behavior are modeled after PostgresSQL 9.2's range types. Deviating from PostgresSQL's -behavoir is considered a bug. +behavior is considered a bug. In addition to the range types there are range sets. A range set is can be viewed -as a mutable list of ranges. A set enables discontinious chunks to be grouped +as a mutable list of ranges. A set enables discontinuous chunks to be grouped together. """ From bf50d6f8c77cc05800633898c7aaaa245141b964 Mon Sep 17 00:00:00 2001 From: cassirer-openai Date: Thu, 5 Jun 2025 11:47:44 +0100 Subject: [PATCH 3/8] Add setup script and fix style (#3) --- benchmark.py | 13 ++++++++----- codex_setup.sh | 16 ++++++++++++++++ doc/conf.py | 14 +++++++------- doc/conftest.py | 6 ++++-- 4 files changed, 35 insertions(+), 14 deletions(-) create mode 100644 codex_setup.sh diff --git a/benchmark.py b/benchmark.py index d329e11..e9d8e1e 100644 --- a/benchmark.py +++ b/benchmark.py @@ -1,4 +1,4 @@ -from timeit import timeit, repeat +from timeit import repeat, timeit from spans import * @@ -28,10 +28,13 @@ def run_benchmark(func, number=None): total_time = sum(repeat(func, repeat=3, number=number)) / 3 - print("{func:.<40} {loops} loops, best of 3: {per_loop} per loop".format( - func=func.__name__ + " ", - loops=number, - per_loop=format_sec(total_time / float(number)))) + print( + "{func:.<40} {loops} loops, best of 3: {per_loop} per loop".format( + func=func.__name__ + " ", + loops=number, + per_loop=format_sec(total_time / float(number)), + ) + ) # Create ranges here to prevent __init__ from affecting test results diff --git a/codex_setup.sh b/codex_setup.sh new file mode 100644 index 0000000..17ef752 --- /dev/null +++ b/codex_setup.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Ensure pip is up to date +python -m pip install --upgrade pip + +# Install Poetry for dependency management if missing +if ! command -v poetry >/dev/null; then + pip install poetry +fi + +# Install project and development dependencies +poetry install --no-interaction + +# TODO: add steps for optional tools or environments if necessary + diff --git a/doc/conf.py b/doc/conf.py index ac240d3..b2238d5 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -17,9 +17,9 @@ # -- Project information ----------------------------------------------------- -project = 'Spans' -copyright = '2022, Andreas Runfalk' -author = 'Andreas Runfalk' +project = "Spans" +copyright = "2022, Andreas Runfalk" +author = "Andreas Runfalk" # -- General configuration --------------------------------------------------- @@ -33,12 +33,12 @@ ] # Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] +templates_path = ["_templates"] # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This pattern also affects html_static_path and html_extra_path. -exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] +exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] # -- Options for HTML output ------------------------------------------------- @@ -46,9 +46,9 @@ # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # -html_theme = 'alabaster' +html_theme = "alabaster" # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] +html_static_path = ["_static"] diff --git a/doc/conftest.py b/doc/conftest.py index 43a65e8..8c2780e 100644 --- a/doc/conftest.py +++ b/doc/conftest.py @@ -1,7 +1,9 @@ -import spans +from datetime import date, datetime, timedelta + import pytest -from datetime import date, datetime, timedelta +import spans + @pytest.fixture(autouse=True) def doctest_fixture(doctest_namespace): From 7e7a20fb212a4fa7eeea107efdd03002534dc6c1 Mon Sep 17 00:00:00 2001 From: cassirer-openai Date: Thu, 5 Jun 2025 12:16:39 +0100 Subject: [PATCH 4/8] Add AGENTS guidelines (#4) * Add AGENTS guidelines * Update AGENTS.md * Update AGENTS.md --- AGENTS.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 AGENTS.md diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..5cdd386 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,5 @@ +# Agent Guidelines + +- **Coding style**: Format code with `black` and order imports with `isort`. +- **Lint**: Run `poetry run black --check spans tests` and `poetry run isort --check spans tests`. +- **Tests**: Run `poetry run pytest`. From f7ee02135d789e2bbf7e4e29fcc36622743fd309 Mon Sep 17 00:00:00 2001 From: cassirer-openai Date: Thu, 5 Jun 2025 12:24:11 +0100 Subject: [PATCH 5/8] docs: add TDD instructions (#5) --- AGENTS.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/AGENTS.md b/AGENTS.md index 5cdd386..855ec38 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -3,3 +3,6 @@ - **Coding style**: Format code with `black` and order imports with `isort`. - **Lint**: Run `poetry run black --check spans tests` and `poetry run isort --check spans tests`. - **Tests**: Run `poetry run pytest`. +- **TDD**: When fixing or adding features, first add a failing test and run it. + After confirming the failure, implement the change and run tests again to + show they pass. Cite both executions in your output. From 026e20500131fc03d459566ab28f20a967ecbaf8 Mon Sep 17 00:00:00 2001 From: cassirer-openai Date: Thu, 5 Jun 2025 12:31:06 +0100 Subject: [PATCH 6/8] Update AGENTS.md --- AGENTS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AGENTS.md b/AGENTS.md index 855ec38..1dab06d 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -5,4 +5,4 @@ - **Tests**: Run `poetry run pytest`. - **TDD**: When fixing or adding features, first add a failing test and run it. After confirming the failure, implement the change and run tests again to - show they pass. Cite both executions in your output. + show they pass. You **MUST** Cite both executions in your output. From 5e67483355302c3a78f8317407d7fcb99853e062 Mon Sep 17 00:00:00 2001 From: cassirer-openai Date: Thu, 5 Jun 2025 14:03:57 +0100 Subject: [PATCH 7/8] Remove setup script and agent guidelines (#6) --- AGENTS.md | 8 -------- codex_setup.sh | 16 ---------------- 2 files changed, 24 deletions(-) delete mode 100644 AGENTS.md delete mode 100644 codex_setup.sh diff --git a/AGENTS.md b/AGENTS.md deleted file mode 100644 index 1dab06d..0000000 --- a/AGENTS.md +++ /dev/null @@ -1,8 +0,0 @@ -# Agent Guidelines - -- **Coding style**: Format code with `black` and order imports with `isort`. -- **Lint**: Run `poetry run black --check spans tests` and `poetry run isort --check spans tests`. -- **Tests**: Run `poetry run pytest`. -- **TDD**: When fixing or adding features, first add a failing test and run it. - After confirming the failure, implement the change and run tests again to - show they pass. You **MUST** Cite both executions in your output. diff --git a/codex_setup.sh b/codex_setup.sh deleted file mode 100644 index 17ef752..0000000 --- a/codex_setup.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -# Ensure pip is up to date -python -m pip install --upgrade pip - -# Install Poetry for dependency management if missing -if ! command -v poetry >/dev/null; then - pip install poetry -fi - -# Install project and development dependencies -poetry install --no-interaction - -# TODO: add steps for optional tools or environments if necessary - From 019cb74d01f0f72c4e53949f2cd054789fdd18fb Mon Sep 17 00:00:00 2001 From: cassirer-openai Date: Thu, 5 Jun 2025 14:05:26 +0100 Subject: [PATCH 8/8] Remove codex setup helpers (#7)