Publication

0.0.3 · active · verified Thu Apr 09

Publication helps maintain public-api-friendly Python modules by preventing unintentional access to private implementation details via introspection. It's currently at version 0.0.3 and is an early-stage library with a focused purpose.

Warnings

Install

Imports

Quickstart

Demonstrates how to use the `@publish` decorator to control the visibility of classes and their members to introspection tools. Note that `publication` affects discoverability, not direct access.

from publication import publish

@publish
class MyPrivateImplementation:
    def _secret_method(self):
        return "This should not be accessible"

    def public_method(self):
        return "This is public"

# Without publication, you could do:
# obj = MyPrivateImplementation()
# print(obj._secret_method())

# With publication, the _secret_method will not be exposed by introspection tools.
# Direct access still works, but tools won't find it.

# Example of usage (not for execution, just demonstrating effect):
# If you run dir(MyPrivateImplementation) or use an IDE's autocomplete,
# _secret_method should not appear.

# For demonstration, direct access still works for runtime logic, but not discovery.
obj = MyPrivateImplementation()
assert obj.public_method() == "This is public"
# print(obj._secret_method()) # This line would still run if uncommented, 
                            # but it won't be discovered by introspection.

view raw JSON →