Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid exposing attributes as optional if they shouldn't need checking. #134

Open
wookie184 opened this issue Sep 10, 2022 · 0 comments
Open

Comments

@wookie184
Copy link
Contributor

wookie184 commented Sep 10, 2022

Users should not need to check that BotBase.stats is not None every time they try to use it, as it never should be None.

We can avoid this by internally using a BotBase._stats attribute that can be None, and exposing a stats property that raises an error if BotBase._stats is None, and otherwise returns the stats client.

I think we should also do this for BotBase.api_client. Whilst it is a slightly different case in that it can be None, it should either always be None or never be None, so the same reasoning applies. If it's always None it makes no sense to access it anyway and it should raise an error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant