Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔨 Maintenance/new python linting recipe #4320

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ fail-under=10

# Files or directories to be skipped. They should be base names, not paths.
ignore=CVS,
migration
migration,
sandbox,
generated_code


# Add files or directories matching the regex patterns to the ignore-list. The
# regex matches against paths and can be in Posix or Windows format.
Expand Down
26 changes: 13 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -492,21 +492,21 @@ nodenv: node_modules ## builds node_modules local environ (TODO)

.PHONY: pylint

pylint: ## Runs python linter framework's wide

pylint: ## python linting
# pylint version info
@/bin/bash -c "pylint --version"
# Running linter
@/bin/bash -c "pylint --jobs=0 --rcfile=.pylintrc $(strip $(shell find services packages -iname '*.py' \
-not -path "*ignore*" \
-not -path "*.venv*" \
-not -path "*/client/*" \
-not -path "*egg*" \
-not -path "*migration*" \
-not -path "*sandbox*" \
-not -path "*-sdk/python*" \
-not -path "*generated_code*" \
-not -path "*build*" \
-not -path "*/director/*"))"
# Running linter in packages and services (except director)
@folders=$$(find $(CURDIR)/services $(CURDIR)/packages -type d -not -path "*/director/*" -name 'src' -exec dirname {} \; | sort -u); \
exit_status=0; \
for folder in $$folders; do \
pushd "$$folder"; \
make pylint || exit_status=1; \
popd; \
done;\
exit $$exit_status
# Running linter elsewhere
@pylint --rcfile=.pylintrc -v $(CURDIR)/tests --ignore=examples
# See exit codes and command line https://pylint.readthedocs.io/en/latest/user_guide/run.html#exit-codes


Expand Down
2 changes: 0 additions & 2 deletions ci/helpers/requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@
# Installing these void e.g. E0611: No name 'UploadFile' in module 'fastapi' (no-name-in-module)
#
aiohttp
docker
fastapi
pyjwt
25 changes: 2 additions & 23 deletions ci/helpers/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# This file is autogenerated by pip-compile with Python 3.10
# by the following command:
#
# pip-compile --output-file=requirements.txt requirements.in
# pip-compile --output-file=requirements.txt --resolver=backtracking --strip-extras requirements.in
#
aiohttp==3.8.3
# via -r requirements.in
Expand All @@ -14,14 +14,8 @@ async-timeout==4.0.2
# via aiohttp
attrs==22.1.0
# via aiohttp
certifi==2022.9.24
# via requests
charset-normalizer==2.1.1
# via
# aiohttp
# requests
docker==6.0.0
# via -r requirements.in
# via aiohttp
fastapi==0.85.1
# via -r requirements.in
frozenlist==1.3.1
Expand All @@ -31,33 +25,18 @@ frozenlist==1.3.1
idna==3.4
# via
# anyio
# requests
# yarl
multidict==6.0.2
# via
# aiohttp
# yarl
packaging==21.3
# via docker
pydantic==1.10.2
# via fastapi
pyjwt==2.6.0
# via -r requirements.in
pyparsing==3.0.9
# via packaging
requests==2.31.0
# via docker
sniffio==1.3.0
# via anyio
starlette==0.20.4
# via fastapi
typing-extensions==4.4.0
# via pydantic
urllib3==1.26.12
# via
# docker
# requests
websocket-client==1.4.1
# via docker
yarl==1.8.1
# via aiohttp
4 changes: 2 additions & 2 deletions tests/performance/locust_files/director_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ def get_services(self):
},
)

def on_start(self):
def on_start(self): # pylint: disable=no-self-use
print("Created User ")

def on_stop(self):
def on_stop(self): # pylint: disable=no-self-use
print("Stopping")
4 changes: 2 additions & 2 deletions tests/performance/locust_files/platform_ping_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ def get_root_slash(self):
def get_health(self):
self.client.get("/v0/health", auth=self.auth)

def on_start(self):
def on_start(self): # pylint: disable=no-self-use
print("Created locust user")

def on_stop(self):
def on_stop(self): # pylint: disable=no-self-use
print("Stopping locust user")
6 changes: 3 additions & 3 deletions tests/performance/locust_files/user_basic_calls.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,19 @@ def timed_get_request(self, route, resource_label):
def get_studies(self):
route = "v0/projects?type=user&offset=0&limit=20"
resource_label = "studies"
response = self.timed_get_request(route, resource_label)
self.timed_get_request(route, resource_label)

@task
def get_templates(self):
route = "v0/projects?type=template&offset=0&limit=20"
resource_label = "templates"
response = self.timed_get_request(route, resource_label)
self.timed_get_request(route, resource_label)

@task
def get_services(self):
route = "v0/catalog/services"
resource_label = "services"
response = self.timed_get_request(route, resource_label)
self.timed_get_request(route, resource_label)

def register(self, username, password):
print("Register User ", username)
Expand Down
2 changes: 1 addition & 1 deletion tests/performance/locust_files/webserver_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def __init__(self, *args, **kwargs):
@task(weight=5)
def get_services(self):
self.client.get(
f"/v0/catalog/services",
"/v0/catalog/services",
)

def on_start(self):
Expand Down
7 changes: 3 additions & 4 deletions tests/swarm-deploy/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,11 @@ def simcore_stack_deployed_services(
# ...

# TODO: find a more reliable way to list services in a stack
core_stack_services: list[Service] = [
service
for service in docker_client.services.list(
core_stack_services: list[Service] = list(
docker_client.services.list(
filters={"label": f"com.docker.stack.namespace={core_stack_namespace}"}
)
] # type: ignore
)

assert (
core_stack_services
Expand Down