Skip to content

Conversation

@JanluOfficial
Copy link

This commit changes the __init__ method of PNConfiguration() to optionally allow the developer to set subscriber_key, publish_key and uuid during initialization instead of setting them post-init. This lets developers initialize their PNConfiguration in one line, as opposed to the 4 lines it took previously, as shown currently by the official pubnub documentation.

image

@pubnub-ops-terraform
Copy link

pubnub-ops-terraform commented Jan 22, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@JanluOfficial JanluOfficial changed the title [Improvement] Letting the developer set subscriber_key, publish_key and uuid for PNConfiguration during initialization [Improvement] Letting the developer initialize subscriber_key, publish_key and uuid for PNConfiguration during initialization Jan 22, 2026
@stephenlb
Copy link
Member

This looks safe, and backward compatible. It's pythonic and supports user initializing the config easily at instantiation. Allows end-user code reduction. I wonder if there is a way to use **kwargs to support member assignment at init()

Comment on lines +17 to +20
def __init__(self,
subscriber_key: str | None = None,
publish_key: str | None = None,
uuid: str | None = None):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JanluOfficial, could you let us know if the following changes work for you?

  1. Renaming subscriber_key to subscribe_key for consistency with the existing attribute name
  2. Changing str | None to Optional[str] to maintain Python 3.9 compatibility

Copy link
Author

@JanluOfficial JanluOfficial Jan 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes will work. subscriber_key was actually just a spelling mistake that I didn't notice. I'm going to implement them once I get home today. Sorry for the late reply.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries. You don’t need to implement these changes. I’ll release them from #228 and let you know once the new version is available

@pubnub-release-bot
Copy link
Contributor

@JanluOfficial this issue is addressed in 10.6.0

@github-actions github-actions bot added the status: done This issue is considered resolved. label Jan 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: done This issue is considered resolved.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants