Skip to content

Python encapsulation: the self._x = branch has no left boundary, myself._x = 1 counts as a private declaration #9454

Backlog

Description

@squid-protocol

Found by the SOP-002 gap-cell decoy suite (protocol SOP-002-v1, epic #8863).

Construct: the python encapsulation branch self\.(?!__\w+__[ \t]*=)_\w+[ \t]*=(?!=) has no left word boundary before self, so an attribute write on any variable whose name ends in self counts as a private-attribute declaration.

Snippet: myself._x = 1
Expected: 0 encapsulation hits (it is not a self._x = ... declaration; obj._x = 1 correctly reads 0). Actual: 1 hit.

Rule: gitgalaxy/standards/language_standards/languages/python.py, encapsulation (contract docs/encapsulation_rule_contract.md: only the declaration self._x = ... counts).

Locked in tests/decoys/test_decoy_python.py as xfail(strict=True).

Activity

  1. added
    bug
    on Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions