Sphinx redefines the pep role to allow for an anchor: https://github.com/sphinx-doc/sphinx/blob/cc314f13e8a98393ab018d83d8957a724a6f338a/sphinx/roles.py#L198
Therefore :pep:`8#specification` should be considered valid unless doc8 is called with --no-sphinx. This is however not the case. Running doc8 on the above RST snippet results in the false positive “D000 PEP number must be a number from 0 to 9999”