aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.flake86
-rw-r--r--Pipfile1
-rw-r--r--Pipfile.lock16
-rw-r--r--snekbox/__init__.py3
-rw-r--r--snekbox/api/resources/eval.py2
-rw-r--r--snekbox/nsjail.py7
6 files changed, 25 insertions, 10 deletions
diff --git a/.flake8 b/.flake8
index 4089dfe..efc7b3d 100644
--- a/.flake8
+++ b/.flake8
@@ -11,10 +11,12 @@ ignore=
# Docstring Quotes
D301,D302,
# Docstring Content
- D400,D401,D402,D404,D405,D406,D407,D408,D409,D410,D411,D412,D413,D414,D416,D417
+ D400,D401,D402,D404,D405,D406,D407,D408,D409,D410,D411,D412,D413,D414,D416,D417,
+ # Type Annotations
+ TYP002,TYP003,TYP101,TYP102,TYP204,TYP206
exclude=
__pycache__,.cache,
venv,.venv
-per-file-ignores=tests/*:D1
+per-file-ignores=tests/*:D1,TYP
import-order-style=pycharm
inline-quotes="
diff --git a/Pipfile b/Pipfile
index dd17306..18e4855 100644
--- a/Pipfile
+++ b/Pipfile
@@ -13,6 +13,7 @@ coverage = ">= 4.4.2, == 4.*"
pre-commit = "~= 1.18"
pydocstyle = "~= 4.0"
flake8 = "~= 3.7.8"
+flake8-annotations = "~=1.0"
flake8-docstrings = "~=1.4"
flake8-bugbear = "~= 19.3"
flake8-import-order = "~= 0.18.1"
diff --git a/Pipfile.lock b/Pipfile.lock
index b541730..0a4147f 100644
--- a/Pipfile.lock
+++ b/Pipfile.lock
@@ -1,7 +1,7 @@
{
"_meta": {
"hash": {
- "sha256": "fa4ef446ed6cd8618914fd2b509e1d437f71cd70140bba4b5b95a4eaf6e53933"
+ "sha256": "1ad99d8fc7a9d131a21df14de468fa708f62bfd2e501cfc40fb76375f255fa13"
},
"pipfile-spec": 6,
"requires": {
@@ -148,6 +148,14 @@
"index": "pypi",
"version": "==3.7.8"
},
+ "flake8-annotations": {
+ "hashes": [
+ "sha256:1309f2bc9853a2d77d578b089d331b0b832b40c97932641e136e1b49d3650c82",
+ "sha256:3ecdd27054c3eed6484139025698465e3c9f4e68dbd5043d0204fcb2550ee27b"
+ ],
+ "index": "pypi",
+ "version": "==1.0.0"
+ },
"flake8-bugbear": {
"hashes": [
"sha256:d8c466ea79d5020cb20bf9f11cf349026e09517a42264f313d3f6fddb83e0571",
@@ -219,10 +227,10 @@
},
"importlib-metadata": {
"hashes": [
- "sha256:9ff1b1c5a354142de080b8a4e9803e5d0d59283c93aed808617c787d16768375",
- "sha256:b7143592e374e50584564794fcb8aaf00a23025f9db866627f89a21491847a8d"
+ "sha256:aa18d7378b00b40847790e7c27e11673d7fed219354109d0e7b9e5b25dc3ad26",
+ "sha256:d5f18a79777f3aa179c145737780282e27b508fc8fd688cb17c7a813e8bd39af"
],
- "version": "==0.20"
+ "version": "==0.23"
},
"junit-xml": {
"hashes": [
diff --git a/snekbox/__init__.py b/snekbox/__init__.py
index 40b76db..98efdff 100644
--- a/snekbox/__init__.py
+++ b/snekbox/__init__.py
@@ -3,6 +3,7 @@ import os
import sys
from gunicorn import glogging
+from gunicorn.config import Config
DEBUG = os.environ.get("DEBUG", False)
@@ -14,7 +15,7 @@ class GunicornLogger(glogging.Logger):
access_fmt = error_fmt
datefmt = None # Use the default ISO 8601 format
- def setup(self, cfg):
+ def setup(self, cfg: Config) -> None:
"""
Set up loggers and set error logger's level to DEBUG if the DEBUG env var is set.
diff --git a/snekbox/api/resources/eval.py b/snekbox/api/resources/eval.py
index c4bd666..c567660 100644
--- a/snekbox/api/resources/eval.py
+++ b/snekbox/api/resources/eval.py
@@ -34,7 +34,7 @@ class EvalResource:
self.nsjail = NsJail()
@validate(REQ_SCHEMA)
- def on_post(self, req, resp):
+ def on_post(self, req: falcon.Request, resp: falcon.Response) -> None:
"""
Evaluate Python code and return stdout, stderr, and the return code.
diff --git a/snekbox/nsjail.py b/snekbox/nsjail.py
index d980f09..d3c893d 100644
--- a/snekbox/nsjail.py
+++ b/snekbox/nsjail.py
@@ -54,7 +54,10 @@ class NsJail:
self._create_parent_cgroups()
@staticmethod
- def _create_parent_cgroups(pids: Path = CGROUP_PIDS_PARENT, mem: Path = CGROUP_MEMORY_PARENT):
+ def _create_parent_cgroups(
+ pids: Path = CGROUP_PIDS_PARENT,
+ mem: Path = CGROUP_MEMORY_PARENT
+ ) -> None:
"""
Create the PIDs and memory cgroups which NsJail will use as its parent cgroups.
@@ -81,7 +84,7 @@ class NsJail:
)
@staticmethod
- def _parse_log(log_lines: Iterable[str]):
+ def _parse_log(log_lines: Iterable[str]) -> None:
"""Parse and log NsJail's log messages."""
for line in log_lines:
match = LOG_PATTERN.fullmatch(line)