Skip to content

Commit

Permalink
Fix Pylint plugin not found error and some lingering Pylint warnings
Browse files Browse the repository at this point in the history
Signed-off-by: Jean Snyman <git@jsnyman.com>
  • Loading branch information
stringlytyped committed May 28, 2024
1 parent 7d8a4ee commit 55eacb9
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- name: Install build dependencies
run: sudo dnf -y install swig
- name: Install Python dependencies
run: sudo dnf -y install python3.6 tox python3-pip python3-gpg
run: sudo dnf -y install python3.6 tox python3-pip
- name: Run lints
run: tox -vv -e 'pylint'
- name: Run mypy
Expand Down
15 changes: 0 additions & 15 deletions keylime/cmd/verifier.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
import asyncio

import tornado.process

from keylime import cloud_verifier_tornado, config, keylime_logging
from keylime.common.migrations import apply
from keylime.mba import mba

# from keylime.web import VerifierServer
from keylime.models.base import db_manager

logger = keylime_logging.init_logging("verifier")


Expand All @@ -19,16 +12,8 @@ def main() -> None:

# Explicitly load and initialize measured boot components
mba.load_imports()

# TODO: Replace call with cloud_verifier_tornado.main() with code below (commented out)
cloud_verifier_tornado.main()

# db_manager.make_engine("cloud_verifier")

# server = VerifierServer()
# tornado.process.fork_processes(0)
# asyncio.run(server.start())


if __name__ == "__main__":
try:
Expand Down
18 changes: 14 additions & 4 deletions keylime/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
from keylime.models.base.da import da_manager
from keylime.models.base.db import db_manager
from keylime.models.registrar import *
# Checks whether script is being invoked by tox in a virtual environment
def is_tox_env():
# Import 'os' inside function to avoid polluting the namespace of any module which imports 'keylime.models'
import os # pylint: disable=import-outside-toplevel

# from keylime.models.verifier import *
return bool(os.environ.get("TOX_ENV_NAME"))


# Only perform automatic imports of submodules if tox is not being used to perform static checks. This is necessary as
# models like RegistrarAgent indirectly import package 'gpg' which is not available in a tox environment as it is
# installed via the system package manager
if not is_tox_env():
from keylime.models.base.da import da_manager
from keylime.models.base.db import db_manager
from keylime.models.registrar import *
5 changes: 0 additions & 5 deletions scripts/check_codestyle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ if [ -z "$(type -P ${PYLINT})" ]; then
exit 1
fi

# Allow python to find gpg package installed with system package manager
PYTHONPATH=$(python3 -c 'import sys; print(":".join(sys.path))')
PYTHONPATH="$PYTHONPATH:/usr/lib/python3/dist-packages"
export PYTHONPATH

${PYLINT} --version

${PYLINT} \
Expand Down

0 comments on commit 55eacb9

Please sign in to comment.