Skip to content

Return None instead of -1 when page is not attached #2371

@MartinThoma

Description

@MartinThoma

Explanation

If a page is not attached to a document, it does not have a page number. So we cannot return a "normal" number.
At the moment, we return -1.

However, callers (users of the library) might not be careful with error handling.

For this reason I suggest to change the behavior to return None.

Pro returning None compared to using -1:

  • It makes intuitive sense what it means
  • It is part of the type annotation and mypy will complain about it if you don't handle that

See #2010

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions