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/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): 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. """ 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", [