Skip to content

Move some fields (exclude, only, etc) to private API in Schema.__init__ #1281

Description

@fuhrysteve

I'd make exclude and only private API because they are used in _normalize_nested_options which is called only at __init__.

I'd also make load_only and dump_only private because setting them after __init__ conflicts with

        self.load_only = set(load_only) or set(self.opts.load_only)
        self.dump_only = set(dump_only) or set(self.opts.dump_only)

Likewise with unknown and context due to

        self.unknown = unknown or self.opts.unknown
        self.context = context or {}

(setting them to None after __init__ wouldn't be the same as in __init__)

At this point, I'm tempted to make everything private. I mean the attributes above plus many, ordered and partial.

Adding the underscore would break libs using marshmallow (like apispec) but that's life. Or is there another way to signify those are private? Like, just a comment in the docstring?

Originally posted by @lafrech in #1258 (comment)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions