Skip to content

Fix AttributeError when creating TPLinkDeviceManager without credentials - #77

Merged
piekstra merged 1 commit into
mainfrom
piekstra/75-fix-auth-token-initialization
Feb 7, 2026
Merged

piekstra merged 1 commit into
mainfrom
piekstra/75-fix-auth-token-initialization

Conversation

@piekstra

@piekstra piekstra commented Jan 30, 2026 •

Copy link
Copy Markdown
Owner

[#75]

Summary

  • Initialize _auth_token to None in __init__ to prevent AttributeError when accessing the attribute before login() is called
  • Add regression test to verify the fix

Problem

When creating a TPLinkDeviceManager without credentials (to set auth token later via set_auth_token()), an AttributeError is raised because _auth_token is never initialized.

This is a valid use case for users who want to cache their auth tokens to avoid API rate limits (see issue discussion).

Test plan

  • Added unit test that verifies _auth_token is accessible and settable without credentials
  • All auth tests pass locally

CI Note

This PR should be rebased after #80 is merged to get CI passing.

Initialize _auth_token to None in __init__ to prevent AttributeError
when accessing the attribute before login() is called.

This allows users to create a TPLinkDeviceManager without credentials
and set the auth token later via set_auth_token(), which is useful for
caching tokens to avoid API rate limits.

Fixes #75
@piekstra
piekstra force-pushed the piekstra/75-fix-auth-token-initialization branch from 025c613 to 0fd22ad Compare February 7, 2026 04:06
@piekstra
piekstra merged commit 9832e84 into main Feb 7, 2026
3 checks passed
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

Successfully merging this pull request may close these issues.

1 participant