Skip to content

Add "no-new-attributes" behavior to our models #7313

Closed
@pradyunsg

Description

@pradyunsg

We should add "no-new-attributes" behavior to all our models in pip._internal.models. It'd be easy to enforce this constraint on them using the interpreter than manually in code reviews. :)

Two of the ways to achieve this using just the standard library are:

  • __slots__
  • collections.namedtuple
  • (both together?)

In case someone (eg. a future me) wants to look up how slots work, take a look at https://stackoverflow.com/a/28059785/1931274.

Originally posted by @pradyunsg in #7310

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: enhancementImprovements to functionalitytype: maintenanceRelated to Development and Maintenance Processes

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions