Package: lib-parameter
lib_parameterVersion v1.1.15 as of 2023-07-14 seeChangelogsmall gist, to return a default value if the parameter is Nonefor mypy type annotation, the parameter usually has the typeOptional[T], the returned type will have the typeTreally not worth a package, just dont know where else to put it.# definitionfromtypingimportTypeVar,OptionalT=TypeVar('T')defget_default_if_none(parameter:Optional[T],default:T)->T:ifparameterisNone:returndefaultelse:returnparameter# usagefromtypingimportOptionalimportlib_parameterx:Optional[int]=Nonex=lib_parameter.get_default_if_none(x,default=1)# now x is from type int, not Optional[int]automated tests, Github Actions, Documentation, Badges, etc. are managed withPizzaCutter(cookiecutter on steroids)Python version required: 3.8.0 or newertested on recent linux with python 3.8, 3.9, 3.10, 3.11, 3.12-dev, pypy-3.9, pypy-3.10 - architectures: amd64100% code coverage, flake8 style checking ,mypy static type checking ,tested underLinux, macOS, Windows, automatic daily builds and monitoringTry it OnlineUsageUsage from CommandlineInstallation and UpgradeRequirementsAcknowledgementsContributeReport IssuesPull RequestCode of ConductLicenseChangelogTry it OnlineYou might try it right away in Jupyter Notebook by using the “launch binder” badge, or clickhereUsageimport the module and check the code - its easy and documented there, including doctest examples.
in case of any questions the usage section might be expanded at a later timeUsage from CommandlineUsage: lib_parameter [OPTIONS] COMMAND [ARGS]...

  small gist,to return a default value if the parameter is None

Options:
  --version                     Show the version and exit.
  --traceback / --no-traceback  return traceback information on cli
  -h, --help                    Show this message and exit.

Commands:
  info  get program informationsInstallation and UpgradeBefore You start, its highly recommended to update pip and setup tools:python -m pip --upgrade pip
python -m pip --upgrade setuptoolsto install the latest release from PyPi via pip (recommended):python -m pip install --upgrade lib_parameterto install the latest release from PyPi via pip, including test dependencies:python -m pip install --upgrade lib_parameter[test]to install the latest version from github via pip:python -m pip install --upgrade git+https://github.com/bitranox/lib_parameter.gitinclude it into Your requirements.txt:# Insert following line in Your requirements.txt:
# for the latest Release on pypi:
lib_parameter

# for the latest development version :
lib_parameter @ git+https://github.com/bitranox/lib_parameter.git

# to install and upgrade all modules mentioned in requirements.txt:
python -m pip install --upgrade -r /<path>/requirements.txtto install the latest development version, including test dependencies from source code:# cd ~
$ git clone https://github.com/bitranox/lib_parameter.git
$ cd lib_parameter
python -m pip install -e .[test]via makefile:
makefiles are a very convenient way to install. Here we can do much more,
like installing virtual environments, clean caches and so on.# from Your shell's homedirectory:$gitclonehttps://github.com/bitranox/lib_parameter.git$cdlib_parameter# to run the tests:$maketest# to install the package$makeinstall# to clean the package$makeclean# uninstall the package$makeuninstallRequirementsfollowing modules will be automatically installed :## Project Requirementsclickcli_exit_toolslib_detect_testenvAcknowledgementsspecial thanks to “uncle bob” Robert C. Martin, especially for his books on “clean code” and “clean architecture”ContributeI would love for you to fork and send me pull request for this project.
-please ContributeLicenseThis software is licensed under theMIT license—Changelognew MAJOR version for incompatible API changes,new MINOR version for added functionality in a backwards compatible mannernew PATCH version for backwards compatible bug fixesv1.1.152023-07-14:add codeql badgemove 3rd_party_stubs outside the src directory to./.3rd_party_stubsadd pypy 3.10 testsadd python 3.12-dev testsv1.1.142023-07-13:require minimum python 3.8remove python 3.7 testsv1.1.132023-07-13:introduce PEP517 packaging standardintroduce pyproject.toml build-systemremove mypy.iniremove pytest.iniremove setup.cfgremove setup.pyremove .bettercodehub.ymlremove .travis.ymlupdate black configclean ./tests/test_cli.pyv1.1.12.22022-06-01: update to github actionscheckout@v3andsetup-python@v3v1.1.12.12022-06-01: update github actions test matrixv1.1.122022-03-29: remedy mypy Untyped decorator makes function “cli_info” untypedv1.1.112022-03-25: fix github actions windows testv1.1.102021-11-22fix “setup.py test”v1.1.92021-11-21: service releaseimplement github actionsimplement check for test environment on __init__v1.1.82020-10-09: service releaseupdate travis build matrix for linux 3.9-devupdate travis build matrix (paths) for windows 3.9 / 3.10v1.1.72020-08-08: service releasefix documentationfix travisdeprecate pycodestyleimplement flake8v1.1.62020-08-07: fix wheelsv1.1.52020-08-01: fix pypi deployv1.1.42020-07-31: initial PyPi release