Skip to content

Commit 86d9015

Browse files
committed
astropy version protect
Signed-off-by: Nathaniel Starkman (@nstarman) <[email protected]>
1 parent 2d70631 commit 86d9015

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

sphinx_astropy/conf/v1.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
from os import path
1616

17+
import astropy
1718
import sphinx
1819
from distutils.version import LooseVersion
1920

@@ -110,17 +111,19 @@ def check_sphinx_version(expected_version):
110111
# https://github.com/numpy/numpydoc/blob/b352cd7635f2ea7748722f410a31f937d92545cc/numpydoc/xref.py#L62-L94
111112
# numpydoc_xref_aliases = {}
112113

113-
# TODO! refactor if #11678 is implemented
114-
from astropy.units.physical import _units_and_physical_types
115114
numpydoc_xref_aliases_astropy_physical_type = {}
116-
for _, ptypes in _units_and_physical_types:
117-
ptypes = {ptypes} if isinstance(ptypes, str) else ptypes
118-
for ptype in ptypes:
119-
key = f"'{ptype}'"
120-
val = f":ref:`:ref: '{ptype}' <astropy:{ptype}>`" # <= intersphinxed.
121-
numpydoc_xref_aliases_astropy_physical_type[key] = val
122-
123-
del ptypes, key, val
115+
if float(astropy.__version__[:3]) >= 4.3:
116+
117+
# TODO! refactor if #11678 is implemented
118+
from astropy.units.physical import _units_and_physical_types
119+
for _, ptypes in _units_and_physical_types:
120+
ptypes = {ptypes} if isinstance(ptypes, str) else ptypes
121+
for ptype in ptypes:
122+
key = f"'{ptype}'"
123+
val = f":ref:`:ref: '{ptype}' <astropy:{ptype}>`" # <= intersphinxed.
124+
numpydoc_xref_aliases_astropy_physical_type[key] = val
125+
126+
del ptypes, key, val
124127

125128
# -- Project information ------------------------------------------------------
126129

0 commit comments

Comments
 (0)