Skip to content

Commit 572236c

Browse files
Migrate to ruff
1 parent bb9d0df commit 572236c

25 files changed

Lines changed: 158 additions & 313 deletions

.devcontainer/Dockerfile

Lines changed: 0 additions & 9 deletions
This file was deleted.

.devcontainer/devcontainer.json

Lines changed: 0 additions & 58 deletions
This file was deleted.

.devcontainer/docker-compose.yaml

Lines changed: 0 additions & 41 deletions
This file was deleted.

.dockerignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,9 @@
11
node_modules/
2+
.github/
3+
.mypy_cache/
4+
.pytest_cache/
5+
__pycache__/
6+
*.pyc
7+
.venv/
8+
.scannerwork/
9+
.ruff_cache/

.github/workflows/python-app.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ jobs:
2727
python-version: ${{ matrix.python-version }}
2828
- name: Install dependencies
2929
run: |
30-
python -m pip install --upgrade pip
31-
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
32-
- name: Lint with pylint
30+
python -m pip install uv
31+
if [ -f requirements.txt ]; then uv pip install -r requirements.txt --system; fi
32+
- name: Lint with ruff
3333
run: |
34-
pylint packet/routes packet
34+
ruff check packet
3535
3636
typecheck:
3737
runs-on: ubuntu-latest
@@ -50,8 +50,8 @@ jobs:
5050
python-version: ${{ matrix.python-version }}
5151
- name: Install dependencies
5252
run: |
53-
python -m pip install --upgrade pip
54-
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
53+
python -m pip install uv
54+
if [ -f requirements.txt ]; then uv pip install -r requirements.txt --system; fi
5555
- name: Typecheck with mypy
5656
run: |
5757
# Disabled error codes to discard errors from imports

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ ENV/
105105

106106
# vscode
107107
.vscode
108+
.devcontainer
108109

109110
# SonarQube
110111
.scannerwork

.pylintrc

Lines changed: 0 additions & 98 deletions
This file was deleted.

Dockerfile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM docker.io/python:3.9-slim-trixie
1+
FROM ghcr.io/astral-sh/uv:python3.9-bookworm-slim
22

33
RUN ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime
44
RUN apt-get -yq update && \
@@ -14,7 +14,7 @@ RUN mkdir /opt/packet
1414
WORKDIR /opt/packet
1515

1616
COPY requirements.txt /opt/packet/
17-
RUN pip install -r requirements.txt
17+
RUN uv pip install -r requirements.txt --system
1818

1919
COPY package.json /opt/packet/
2020
COPY yarn.lock /opt/packet/
@@ -32,4 +32,9 @@ RUN gulp production && \
3232
# Set version for apm
3333
RUN echo "export DD_VERSION=\"$(python3 packet/git.py)\"" >> /tmp/version
3434

35+
RUN groupadd -r packet && useradd --no-log-init -r -g packet packet && \
36+
chown -R packet:packet /opt/packet
37+
38+
USER packet
39+
3540
CMD ["/bin/bash", "-c", "source /tmp/version && ddtrace-run gunicorn packet:app --bind=0.0.0.0:8080 --access-logfile=- --timeout=600"]

Dockerfile.dev

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM docker.io/python:3.9-slim-trixie
1+
FROM ghcr.io/astral-sh/uv:python3.9-bookworm-slim
22

33
RUN ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime
44
RUN apt-get -yq update && \
@@ -14,7 +14,7 @@ RUN mkdir /opt/packet
1414
WORKDIR /opt/packet
1515

1616
COPY requirements.txt /opt/packet/
17-
RUN pip install -r requirements.txt
17+
RUN uv pip install -r requirements.txt --system
1818

1919
COPY package.json /opt/packet/
2020
COPY yarn.lock /opt/packet/
@@ -29,6 +29,11 @@ RUN gulp production && \
2929
apt-get -yq autoremove && \
3030
apt-get -yq clean all
3131

32+
RUN groupadd -r packet && useradd --no-log-init -r -g packet packet && \
33+
chown -R packet:packet /opt/packet
34+
35+
USER packet
36+
3237
EXPOSE 8000
3338

3439
CMD ["/bin/bash", "-c", "python3 wsgi.py"]

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,12 @@ All DB commands are from the `Flask-Migrate` library and are used to configure D
133133
docs [here](https://flask-migrate.readthedocs.io/en/latest/) for details.
134134

135135
## Code standards
136-
This project is configured to use Pylint and mypy. Commits will be pylinted and typechecked by GitHub actions and if the
136+
This project is configured to use ruff and mypy. Commits will be ruffed and typechecked by GitHub actions and if the
137137
score drops your build will fail blocking you from merging. To make your life easier just run it before making a PR.
138138

139-
To run pylint and mypy use these commands:
139+
To run ruff and mypy use these commands:
140140
```bash
141-
pylint packet/routes packet
141+
ruff check packet
142142
mypy --disable-error-code import --disable-error-code name-defined --disallow-untyped-defs --exclude routes packet
143143
```
144144

0 commit comments

Comments
 (0)