Skip to content

Make most parameters of PdfReader and PdfWriter initialization keyword-only #3618

@stefan6419846

Description

@stefan6419846

Explanation

Instantiating a PdfReader or PdfWriter currently allows for passing everything as positional arguments. This is not optimal, especially given that PdfWriter currently has some rather complex logic and associated attributes to determine how to handle the input parameter, leading to issues and the docstring that fileobj and clone_from are identical for compatibility.

The goal is to evaluate migrating most of the parameters to be keyword-only with a proper deprecation period and associated tests.

Main aspects:

  • PdfReader
    • stream is a required parameter, but can be positional.
    • All remaining parameters should be keyword-only.
  • PdfWriter
    • Empty instances can still be created.
    • fileobj can be positional or keyword. It should always be used for writing as well.
    • clone_from should be keyword-only. It will never be used for writing.
    • All remaining parameters should be keyword-only.
    • Internal attributes like temp_fileobj and fileobj should not be exposed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    PdfReaderThe PdfReader component is affectedPdfWriterThe PdfWriter component is affectedbreaking-changeA planned breaking change

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions