Skip to content

Commit 5c08262

Browse files
committed
Direct import statements instead of importlib
The call to importlib was to satisfy a linter used previously. Using direct imports is simpler and more meaningful for mypy.
1 parent a4b1f83 commit 5c08262

File tree

2 files changed

+2
-9
lines changed

2 files changed

+2
-9
lines changed

stagpy/__init__.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,18 @@
1717
"""
1818

1919
from __future__ import annotations
20-
import importlib
2120
import os
2221
import pathlib
2322
import shutil
2423
import signal
2524
import sys
26-
import typing
2725

2826
from pkg_resources import get_distribution, DistributionNotFound
2927
from setuptools_scm import get_version
3028
from loam.manager import ConfigurationManager
3129

3230
from . import config
3331

34-
if typing.TYPE_CHECKING:
35-
from typing import Any
36-
3732

3833
def _env(var: str) -> bool:
3934
"""Return whether var is set to True."""
@@ -74,7 +69,7 @@ def _check_config():
7469

7570
def load_mplstyle():
7671
"""Try to load conf.plot.mplstyle matplotlib style."""
77-
plt: Any = importlib.import_module('matplotlib.pyplot')
72+
import matplotlib.pyplot as plt
7873
if conf.plot.mplstyle:
7974
for style in conf.plot.mplstyle.split():
8075
found = False

stagpy/__main__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""The stagpy module is callable."""
22

3-
import importlib
43
import signal
54
import sys
65
import warnings
@@ -13,8 +12,7 @@ def main():
1312
if not DEBUG:
1413
signal.signal(signal.SIGINT, sigint_handler)
1514
warnings.simplefilter('ignore')
16-
args = importlib.import_module('stagpy.args')
17-
error = importlib.import_module('stagpy.error')
15+
from . import args, error
1816
try:
1917
args.parse_args()()
2018
except error.StagpyError as err:

0 commit comments

Comments
 (0)