Skip to content

Conversation

mateusz-twarog-deepsense
Copy link
Contributor

@mateusz-twarog-deepsense mateusz-twarog-deepsense commented Jul 8, 2025

Resolves #581 and #587

@mateusz-twarog-deepsense mateusz-twarog-deepsense marked this pull request as ready for review July 29, 2025 05:59
@mateusz-twarog-deepsense mateusz-twarog-deepsense changed the title Create lint pipeline Create lint pipeline and fix errors Aug 19, 2025
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '>=1.22'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason we're pinning the python version and not the go version?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I must have copy-pasted this config without thinking. In theory it should be fine since go cares about backward compatibility, but pinning makes more sense.

Comment on lines +92 to +101
python -m mypy --ignore-missing-imports --exclude 'racetrack_client/build' racetrack_client; e1=$$?;\
python -m mypy --ignore-missing-imports racetrack_commons; e2=$$?;\
python -m mypy --ignore-missing-imports --exclude 'lifecycle/lifecycle/django/registry/migrations' lifecycle; e3=$$?;\
python -m mypy --ignore-missing-imports image_builder; e4=$$?;\
python -m mypy --ignore-missing-imports dashboard; e5=$$?;\
python -m flake8 --ignore E501 --per-file-ignores="__init__.py:F401 lifecycle/lifecycle/event_stream/server.py:E402" \
lifecycle image_builder dashboard; e6=$$?;\
python -m pylint --disable=R,C,W \
lifecycle/lifecycle image_builder/image_builder dashboard/dashboard; e7=$$?;\
exit "$$(( e1 || e2 || e3 || e4 || e5 || e6 || e7 ))"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not enough of a Makefile guru to understand what is going on here. It seems like we previously ignored non-zero exit codes, but now we exit with the cumulative or of every exit code? Why, and what does it even mean to or an exit code - is it just to check if any are truthy (I.E, nonzero)?

Also, does this even work? I was under the impression that Makefiles exited upon a nonzero return code. With the initial dash deleted, that's the case here, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This basically takes all exit codes and "or" on them will return 0 if all of them were 0, some other code if at least one was not 0. It works, but it's ugly - this is purely bash syntax used, since it's makefile maybe I could split it into multiple commands and last one dependent on them? I would need to experiment a bit.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it works then I'm not too fussed either way. Makefiles are not exactly known for their graceful syntax

Comment on lines +24 to +26
class Hash(Protocol):
def __call__(self, string: ReadableBuffer = b"", *, usedforsecurity: bool = True) -> hashlib._Hash:
...
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this do except be a placeholder? If it really is only a placeholder, why?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, this one is weird. There is no type I could import from hash library that would allow me to correctly type digest few lines below, so I had to write correct interface myself.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh. Put a comment in about it, otherwise this just looks wrong.

Comment on lines +224 to +226
def connect(cls, *args, **kwargs) -> "PgConnection":
try:
return Connection.connect(*args, **kwargs)
return super(PgConnection, cls).connect(*args, **kwargs)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This again seems like a non-linting change, what are we fixing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typing was incorrect here, because it involved a bit of magic, like connect returning object of its own type. Functionally we are doing exactly the same thing as before, but with a syntax that makes more sense for mypy.

try:
user = User.objects.get(username='admin')
except User.DoesNotExist:
except User.DoesNotExist: # pylint: disable=E1101
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we ignore the linter, I think a comment explaining why is a good idea.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now I regret not making notes when doing this - I will have to go through those ignores one by one.

Comment on lines +159 to +161
method: str = record.args[1] # type: ignore
uri: str = record.args[2] # type: ignore
response_code: int = record.args[4] # type: ignore
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, if we're ignoring the linter, I think we should explain why

return fastapi_app.openapi_schema

fastapi_app.openapi = custom_openapi
fastapi_app.openapi = custom_openapi # type: ignore
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, if we're ignoring the linter, I think we should explain why


metrics_app = make_wsgi_app(REGISTRY)
api.mount('/metrics', WSGIMiddleware(metrics_app))
api.mount('/metrics', WSGIMiddleware(metrics_app)) # type: ignore
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, if we're ignoring the linter, I think we should explain why

wheel==0.38.4
types-PyYAML==6.0.12
types-python-dateutil==2.9.0.20250708
types-Markdown==3.3.18
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No newline at end of file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create lint pipeline

2 participants