Skip to content

Commit 984804c

Browse files
Merge pull request #20479 from neutrinoceros/typ/config
TYP: fix remaining type-check type errors in astropy/config
2 parents a0380a5 + 281d83b commit 984804c

3 files changed

Lines changed: 10 additions & 5 deletions

File tree

‎astropy/config/configuration.py‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,8 @@ class _Conf(config.ConfigNamespace):
305305
Rootname sets the base path for all config files.
306306
"""
307307

308+
name: str # this attribute is set by the parent ConfigNamespace
309+
308310
def __init__(
309311
self, defaultvalue="", description=None, cfgtype=None, module=None, aliases=None
310312
):
@@ -599,13 +601,12 @@ def get_config(
599601
from cannot be determined.
600602
"""
601603
if packageormod is None:
602-
packageormod = find_current_module(2)
603-
if packageormod is None:
604+
if (mod := find_current_module(2)) is None:
604605
msg1 = "Cannot automatically determine get_config module, "
605606
msg2 = "because it is not called from inside a valid module"
606607
raise RuntimeError(msg1 + msg2)
607608
else:
608-
packageormod = packageormod.__name__
609+
packageormod = mod.__name__
609610

610611
_autopkg = True
611612

‎astropy/logger.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848

4949

5050
# Initialize by calling _init_log()
51-
log = None
51+
log: logging.Logger
5252

5353

5454
class LoggingError(Exception):
@@ -109,7 +109,7 @@ class Conf(_config.ConfigNamespace):
109109
conf = Conf()
110110

111111

112-
def _init_log():
112+
def _init_log() -> logging.Logger:
113113
"""Initializes the Astropy log--in most circumstances this is called
114114
automatically when importing astropy.
115115
"""

‎pyproject.toml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,3 +1061,7 @@ exclude = [
10611061
# otherwise pick up as an implicit namespace package.
10621062
"astropy/cosmology/data/",
10631063
]
1064+
modules = [
1065+
# Specific config modules
1066+
"astropy.config.configuration",
1067+
]

0 commit comments

Comments
 (0)