CSSS / csss-site-backend

CSSS Website Backend (2024 - Present)
4 stars 0 forks source link

Null checking on Discord module #46

Closed DerpyWasHere closed 3 months ago

DerpyWasHere commented 3 months ago

As referenced in PR #26, the get_channel() and get_role_by_id() functions don't perform any null checking and could potentially operate on empty lists. This is less of an issue on get_role_by_id(), but we may want to be more fussy on get_channel().

I suggest we either perform null checking on the result of next as the dataclasses (Channel) expect non-null values, or assign default values to the next() calls.

DerpyWasHere commented 3 months ago

Upon further review, simply returning None seems to be a good enough solution. We might instead want to ensure that the function has some sort of docstring stating that the channel id (cid) must be exact else the function returns None.

EarthenSky commented 3 months ago

I opted to use typing to convey this (returning a union with the None type)