Skip to content

Commit 2bef415

Browse files
authored
Some small fixes in typing and mypy config (#527)
1 parent ec0696a commit 2bef415

File tree

8 files changed

+28
-11
lines changed

8 files changed

+28
-11
lines changed

.gitignore

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
11
.DS_Store
2-
.coverage
2+
33
.idea
4+
.vscode
5+
46
.mypy_cache
5-
.tmpdirs
67
.pytest_cache
8+
.tmpdirs
9+
710
local_config.yaml
811

12+
.coverage
13+
cov.xml
14+
15+
build
16+
dist
17+
gnupg
18+
irrd.egg-info
19+
920
syntax: glob
1021
__pycache__
1122
_build

docs/development/development-setup.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ Mypy and flake8
8585
In addition to the tests, this project uses `mypy` for type checking and `flake8`
8686
for style checking. To run these, run::
8787

88-
mypy irrd --ignore-missing-imports
88+
mypy irrd
8989
flake8
9090

9191
If all is well, neither command should provide output.

irrd/conf/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ class ConfigurationError(ValueError):
142142
# testing_overrides can be set to a DottedDict, and is used
143143
# to override settings while testing, using the config_override
144144
# fixture.
145-
testing_overrides = None
145+
testing_overrides: Any = None
146146

147147

148148
class Configuration:
@@ -174,7 +174,7 @@ def __init__(self, user_config_path: Optional[str]=None, commit=True):
174174
logfile_path = self.get_setting_live('log.logfile_path')
175175
if logging_config_path:
176176
spec = importlib.util.spec_from_file_location("logging_config", logging_config_path)
177-
config_module = importlib.util.module_from_spec(spec)
177+
config_module = importlib.util.module_from_spec(spec) # type: ignore
178178
spec.loader.exec_module(config_module) # type: ignore
179179
self.logging_config = config_module.LOGGING # type: ignore
180180
logging.config.dictConfig(self.logging_config)
@@ -427,7 +427,7 @@ def _check_is_str(self, config, key, required=True):
427427
return config.get(key) is None or isinstance(config.get(key), str)
428428

429429

430-
configuration = None
430+
configuration: Optional[Configuration] = None
431431

432432

433433
def get_configuration() -> Optional[Configuration]:

irrd/daemon/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def sigterm_handler(signum, frame):
171171
logging.info(f'Main process exiting')
172172

173173

174-
def get_configured_owner() -> Tuple[int, int]:
174+
def get_configured_owner() -> Tuple[Optional[int], Optional[int]]:
175175
uid = gid = None
176176
user = get_setting('user')
177177
group = get_setting('group')

irrd/mirroring/parsers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ class NRTMStreamParser(MirrorParser):
292292
"""
293293
first_serial = -1
294294
last_serial = -1
295-
nrtm_source = None
295+
nrtm_source: Optional[str] = None
296296
_current_op_serial = -1
297297

298298
def __init__(self, source: str, nrtm_data: str, database_handler: DatabaseHandler) -> None:

irrd/scripts/rpsl_read.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import sys
99

1010
from pathlib import Path
11-
from typing import Set
11+
from typing import Optional, Set
1212

1313
from irrd.storage.models import JournalEntryOrigin
1414

@@ -26,7 +26,7 @@ class RPSLParse:
2626
obj_errors = 0
2727
obj_unknown = 0
2828
unknown_object_classes: Set[str] = set()
29-
database_handler = None
29+
database_handler: Optional[DatabaseHandler] = None
3030

3131
def main(self, filename, strict_validation, database, show_info=True):
3232
self.show_info = show_info

irrd/storage/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from irrd.conf import get_setting
88

9-
engine = None
9+
engine: sa.engine.Engine = None
1010

1111

1212
def get_engine():

setup.cfg

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,9 @@ omit =
3232

3333
[tool:pytest]
3434
log_level=DEBUG
35+
36+
[mypy]
37+
ignore_missing_imports = True
38+
install_types = True
39+
non_interactive = True
40+
exclude = irrd/storage/alembic/*

0 commit comments

Comments
 (0)