Check type¶
Check utility functions
Module private variables
- logging_strict.util.check_type.__all__: tuple[str, str, str, str, str] = ("check_type_path", "is_not_ok", "is_ok", "check_int_verbosity", "check_start_folder_importable")¶
Exported objects from this module
Module objects
- logging_strict.util.check_type.check_int_verbosity(test)¶
Check verbosity is an integer with value either 1 or 2
- logging_strict.util.check_type.check_start_folder_importable(folder_start)¶
Folder containing tests, must have a
__init__.pyfile. Super easy to forget. The required file, indicates the test folder is within a “package”. Not having that file, unittest discover will ungraciously complain.To reproduce the issue, on a folder not containing a
__init__.pyfilepython -m unittest discover -t . -s "tests/util" -p 'test_check_type*.py'
ImportError: Start directory is not importable: ‘[top level folder absolute path]/tests/util’With the laughable and useless exit code 1. Exit code 1 and 2 (insufficient permissions) indicates the coder hates you and doesn’t care about UX.
Have a searing hate for error messages that offer no suggestions on how to resolve the issue. Forcing a web search. Bad UX! BAD!! Also unnecessarily bleeds a traceback. Should produce only an exit code
python -m unittest discover --help
Should contain a section, EXIT CODES, listing the exit codes with the message and suggestion on how to resolve the issue. Added benefit, the entrypoint becomes testable. Call the entrypoint in a subprocess and assert the return value(s)
Did figure out why without a web search, but coulda just said, “Make a __init__.py” in that folder, touch [folder path]/__init__.py”
- Parameters:
- Returns:
Trueif folder contains__init__.pyfile otherwiseFalse- Return type:
- Raises:
TypeError– Unsupported type. Expected folder absolute pathValueError– Cannot expand session user home folder or path is invalidNotADirectoryError– Not a folder. Expected a folder absolute path
- logging_strict.util.check_type.check_type_path(module_path, *, msg_context=None)¶
Check
logging_strict.util.check_type.check_type_path.params.module_pathis aPath- Parameters:
- Returns:
Parameter coersed to
Path- Return type:
- Raises:
ValueError– Cannot expand session user home folder or path is invalid
- logging_strict.util.check_type.is_not_ok(test)¶
Check not
None, not a str, or an empty str