Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F7123993
D2033.id6818.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Subscribers
None
D2033.id6818.diff
View Options
diff --git a/.gitignore b/.gitignore
--- a/.gitignore
+++ b/.gitignore
@@ -11,3 +11,4 @@
version.txt
/.hypothesis/
/.tox/
+.mypy_cache/
diff --git a/MANIFEST.in b/MANIFEST.in
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -4,3 +4,4 @@
include requirements-swh.txt
include version.txt
recursive-include swh/scheduler/sql *.sql
+recursive-include swh py.typed
diff --git a/mypy.ini b/mypy.ini
new file mode 100644
--- /dev/null
+++ b/mypy.ini
@@ -0,0 +1,27 @@
+[mypy]
+namespace_packages = True
+warn_unused_ignores = True
+
+
+# 3rd party libraries without stubs (yet)
+
+[mypy-arrow.*]
+ignore_missing_imports = True
+
+[mypy-celery.*]
+ignore_missing_imports = True
+
+[mypy-elasticsearch.*]
+ignore_missing_imports = True
+
+[mypy-kombu.*]
+ignore_missing_imports = True
+
+[mypy-pkg_resources.*]
+ignore_missing_imports = True
+
+[mypy-psycopg2.*]
+ignore_missing_imports = True
+
+[mypy-pytest.*]
+ignore_missing_imports = True
diff --git a/swh/__init__.py b/swh/__init__.py
--- a/swh/__init__.py
+++ b/swh/__init__.py
@@ -1 +1,4 @@
-__path__ = __import__('pkgutil').extend_path(__path__, __name__)
+from typing import Iterable
+
+__path__ = __import__('pkgutil').extend_path(__path__,
+ __name__) # type: Iterable[str]
diff --git a/swh/scheduler/__init__.py b/swh/scheduler/__init__.py
--- a/swh/scheduler/__init__.py
+++ b/swh/scheduler/__init__.py
@@ -3,6 +3,8 @@
# License: GNU General Public License version 3, or any later version
# See top-level LICENSE file for more information
+from typing import Any, Dict
+
# Percentage of tasks with priority to schedule
PRIORITY_SLOT = 0.6
@@ -16,7 +18,7 @@
})
}
# current configuration. To be set by the config loading mechanism
-CONFIG = {}
+CONFIG = {} # type: Dict[str, Any]
def compute_nb_tasks_from(num_tasks):
diff --git a/swh/scheduler/celery_backend/config.py b/swh/scheduler/celery_backend/config.py
--- a/swh/scheduler/celery_backend/config.py
+++ b/swh/scheduler/celery_backend/config.py
@@ -18,6 +18,8 @@
import requests
+from typing import Any, Dict
+
from swh.scheduler import CONFIG as SWH_CONFIG
from swh.core.config import load_named_config, merge_configs
@@ -177,7 +179,7 @@
INSTANCE_NAME = os.environ.get(CONFIG_NAME_ENVVAR)
CONFIG_NAME = os.environ.get('SWH_CONFIG_FILENAME')
-CONFIG = {}
+CONFIG = {} # type: Dict[str, Any]
if CONFIG_NAME:
# load the celery config from the main config file given as
@@ -186,7 +188,7 @@
# celery specific configuration.
SWH_CONFIG.clear()
SWH_CONFIG.update(load_named_config(CONFIG_NAME))
- CONFIG = SWH_CONFIG.get('celery')
+ CONFIG = SWH_CONFIG.get('celery', default={})
if not CONFIG:
# otherwise, back to compat config loading mechanism
diff --git a/swh/scheduler/py.typed b/swh/scheduler/py.typed
new file mode 100644
--- /dev/null
+++ b/swh/scheduler/py.typed
@@ -0,0 +1 @@
+# Marker file for PEP 561.
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Dec 20 2024, 8:49 AM (11 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3226891
Attached To
D2033: typing: minimal changes to make a no-op mypy run pass
Event Timeline
Log In to Comment