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 either return None or raise an Exception. I'm not sure what is better.
Pro returning None:
- 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
- Callers just need to check for None and don't need to catch an exception - which I personally prefer.
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 either return
Noneor raise an Exception. I'm not sure what is better.Pro returning
None: