Skip to content

Commit 1001d69

Browse files
committed
use astropy for minversion check
The version check only runs if astropy is installed. Also update numpydoc xref ignores, from review comment. Signed-off-by: Nathaniel Starkman (@nstarman) <[email protected]>
1 parent c531506 commit 1001d69

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

sphinx_astropy/conf/v1.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
else:
2626
ASTROPY_INSTALLED = True
2727

28+
from astropy.utils import minversion
29+
2830

2931
# -- General configuration ----------------------------------------------------
3032

@@ -107,10 +109,9 @@ def check_sphinx_version(expected_version):
107109
# parameter type descriptions that may be confused for classes of the same
108110
# name. This can be overwritten or modified in packages and is provided here for
109111
# convenience.
110-
numpydoc_xref_ignore = {
111-
"type", "optional", "default", "or", "of", "method", "instance",
112-
"class", "subclass", "keyword-only", "default", "thereof",
113-
}
112+
numpydoc_xref_ignore = {"or", "of", "thereof",
113+
"default", "optional", "keyword-only",
114+
"instance", "type", "class", "subclass", "method"}
114115

115116
# Mappings to fully qualified paths (or correct ReST references) for the
116117
# aliases/shortcuts used when specifying the types of parameters.
@@ -126,8 +127,8 @@ def check_sphinx_version(expected_version):
126127
# Aliases to Astropy's glossary. In packages these can be turned on with
127128
# ``numpydoc_xref_aliases.update(numpydoc_xref_aliases_astropy_glossary)``
128129
# (if astropy is in the intersphinx mapping).
129-
numpydoc_xref_aliases_astropy_glossary = {} # works even if older Astropy
130-
if ASTROPY_INSTALLED and float(astropy.__version__[:3]) >= 4.3:
130+
numpydoc_xref_aliases_astropy_glossary = {} # works even if no Astropy
131+
if ASTROPY_INSTALLED and minversion(astropy, "4.3"):
131132
numpydoc_xref_aliases_astropy_glossary = {
132133
# general
133134
"-like": ":term:`astropy:-like`",
@@ -147,8 +148,8 @@ def check_sphinx_version(expected_version):
147148
# Aliases to Astropy's physical types. In packages these can be turned on with
148149
# ``numpydoc_xref_aliases.update(numpydoc_xref_aliases_astropy_physical_type)``
149150
# (if astropy is in the intersphinx mapping).
150-
numpydoc_xref_aliases_astropy_physical_type = {} # works even if older astropy
151-
if ASTROPY_INSTALLED and float(astropy.__version__[:3]) >= 4.3:
151+
numpydoc_xref_aliases_astropy_physical_type = {} # works even if no astropy
152+
if ASTROPY_INSTALLED and minversion(astropy, "4.3"):
152153

153154
from astropy.units.physical import _name_physical_mapping
154155
for ptype in _name_physical_mapping.keys():

0 commit comments

Comments
 (0)