diff --git a/cfig/tests/test_config.py b/cfig/tests/test_config.py index 60af0e3..5e990a8 100644 --- a/cfig/tests/test_config.py +++ b/cfig/tests/test_config.py @@ -58,7 +58,7 @@ class TestConfig: """The first number to sum.""" try: return int(val) - except ValueError: + except (ValueError, TypeError): raise cfig.InvalidValueError("Not an int.") @basic_config.optional() @@ -66,7 +66,7 @@ class TestConfig: """The second number to sum.""" try: return int(val) - except ValueError: + except (ValueError, TypeError): raise cfig.InvalidValueError("Not an int.") yield basic_config diff --git a/docs/quickstart.rst b/docs/quickstart.rst index 7895deb..26bc70b 100644 --- a/docs/quickstart.rst +++ b/docs/quickstart.rst @@ -125,7 +125,7 @@ This allows us to perform some expensive operations inside, such as connecting t """The maximum number of users that will be able to login to this application.""" try: return int(val) - except ValueError: + except (ValueError, TypeError): raise cfig.InvalidValueError("Not an int.") We can see that the new ``MAX_USERS`` configurable value processes the input string by trying to cast it into an :class:`int`, and raises a :exc:`~cfig.errors.InvalidValueError` containing the error message to display to the user if the cast fails. @@ -168,7 +168,7 @@ To facilitate configuration on the users' part, :mod:`cfig` provides an integrat """The maximum number of users that will be able to login to this application.""" try: return int(val) - except ValueError: + except (ValueError, TypeError): raise cfig.InvalidValueError("Not an int.") if __name__ == "__main__":