Skip to content

Instantly share code, notes, and snippets.

@chadfennell
Created August 26, 2025 16:56
Show Gist options
  • Select an option

  • Save chadfennell/709a50088c027f53f518d9a5351d32cf to your computer and use it in GitHub Desktop.

Select an option

Save chadfennell/709a50088c027f53f518d9a5351d32cf to your computer and use it in GitHub Desktop.
Awesome (looking) Python Libraries

Result (monad)

https://pypi.org/project/result/

from result import Ok, Err, Result, is_ok, is_err

def get_user_by_email(email: str) -> Result[User, str]:
    """
    Return the user instance or an error message.
    """
    if not user_exists(email):
        return Err('User does not exist')
    if not user_active(email):
        return Err('User is inactive')
    user = get_user(email)
    return Ok(user)

user_result = get_user_by_email(email)
if isinstance(user_result, Ok): # or `is_ok(user_result)`
    # type(user_result.ok_value) == User
    do_something(user_result.ok_value)
else: # or `elif is_err(user_result)`
    # type(user_result.err_value) == str
    raise RuntimeError('Could not fetch user: %s' % user_result.err_value)

PyToolz (functional library)

https://toolz.readthedocs.io/en/latest/

Hypothesis (property based testing)

https://hypothesis.readthedocs.io/en/latest/

from hypothesis import [given](https://hypothesis.readthedocs.io/en/latest/reference/api.html#hypothesis.given "hypothesis.given"), strategies as st

[@given](https://hypothesis.readthedocs.io/en/latest/reference/api.html#hypothesis.given "hypothesis.given")([st.lists](https://hypothesis.readthedocs.io/en/latest/reference/strategies.html#hypothesis.strategies.lists "hypothesis.strategies.lists")([st.integers](https://hypothesis.readthedocs.io/en/latest/reference/strategies.html#hypothesis.strategies.integers "hypothesis.strategies.integers")() | [st.floats](https://hypothesis.readthedocs.io/en/latest/reference/strategies.html#hypothesis.strategies.floats "hypothesis.strategies.floats")()))
def test_sort_correct(lst):
    # lst is a random list of numbers
    assert my_sort(lst) == [sorted](https://docs.python.org/3/library/functions.html#sorted "sorted")(lst)

test_sort_correct()

Pydandic Setttings (config management and validation)

https://docs.pydantic.dev/latest/concepts/pydantic_settings/

HTTTPx (request library)

https://www.python-httpx.org/

  • A lot more features than older libraries

FastAPI Pagination

https://uriyyo-fastapi-pagination.netlify.app/

Marimo (python notebook)

https://docs.marimo.io/

Astral (linting, type checking - fast)

https://astral.sh/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment