Skip to content

Commit

Permalink
use uv and ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreyBozhko committed Apr 6, 2024
1 parent ed8fc70 commit f1e5bf4
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 71 deletions.
14 changes: 4 additions & 10 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
FROM python:3.9-buster@sha256:a21bc1f5190fa4f5d13dbdec6adc8d65ae2d3025411ecab367f616831dd570cb
RUN pip install --no-cache-dir --upgrade pip==22.3.1 setuptools==65.6.3 wheel==0.42.0
RUN pip install --no-cache-dir --upgrade pip==22.3.1 setuptools==65.6.3 wheel==0.43.0 \
&& pip install --no-cache-dir uv

ENV PIP_PREFIX=/usr/local/share/pip_global
ENV PATH=${PATH}:${PIP_PREFIX}/bin
ENV PYTHONPATH=${PYTHONPATH}:${PIP_PREFIX}/lib/python3.9/site-packages:/workspaces/expense-bot/src
ENV PYTHONPATH=${PYTHONPATH}:/workspaces/expense-bot/src

RUN groupadd docker && \
useradd -r -u 1001 -g docker vscode && \
mkdir -p /home/vscode && \
chown -R vscode:docker /home/vscode && \
mkdir -p ${PIP_PREFIX} && \
chown -R vscode:docker ${PIP_PREFIX}
chown -R vscode:docker /home/vscode

RUN apt-get update \
&& apt-get -y install --no-install-recommends apt-utils dialog 2>&1 \
Expand All @@ -24,6 +21,3 @@ RUN apt-get update \
&& rm -rf /var/lib/apt/lists/*

USER vscode

RUN pip install --no-cache-dir 'pip-tools==6.12.1' 'wheel==0.42.0' \
&& pip install --no-cache-dir pylint mypy black flake8
13 changes: 9 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ jobs:

- name: Install Dependencies
run: |
python -m pip install --upgrade pip
python -m venv venv
python -m pip install --upgrade uv
uv venv venv
source venv/bin/activate
pip install --upgrade pip setuptools wheel
pip install -r reqs/requirements.txt -r reqs/requirements-dev.txt
uv pip install --upgrade setuptools wheel
uv pip install -r reqs/requirements.txt -r reqs/requirements-dev.txt
- name: Run Tests (pytest)
env:
Expand Down Expand Up @@ -61,3 +61,8 @@ jobs:
run: |
source venv/bin/activate
pylint src/
- name: Lint Code (ruff)
run: |
source venv/bin/activate
ruff check src/
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ dmypy.json
# Cython debug symbols
cython_debug/

# ruff
.ruff_cache/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
Expand Down
13 changes: 12 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ dev = [
"flake8-pyproject",
"google-api-python-client-stubs",
"mypy",
"pip-tools",
"pylint",
"pytest",
"ruff",
"setuptools==65.6.3",
"wheel",
]

Expand All @@ -55,3 +56,13 @@ line_length = 78
[tool.pylint.main]
good-names = ["dt", "dp"]
disable = ["R0801", "R0903"]

[tool.ruff.lint]
select = [
"E",
"F",
"B",
"SIM",
"I",
"R",
]
55 changes: 9 additions & 46 deletions reqs/requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
#
# This file is autogenerated by pip-compile with Python 3.9
# by the following command:
#
# pip-compile --extra=dev --output-file=reqs/requirements-dev.txt --resolver=backtracking pyproject.toml
#
# This file was autogenerated by uv via the following command:
# uv pip compile --extra=dev pyproject.toml -o reqs/requirements-dev.txt
aiofiles==23.2.1
# via aiogram
aiogram==3.2.0
# via expense-bot (pyproject.toml)
aiohttp==3.9.3
# via aiogram
aiosignal==1.2.0
Expand All @@ -23,18 +18,12 @@ attrs==21.4.0
# aiohttp
# pytest
awslambdaric==2.0.4
# via expense-bot (pyproject.toml)
black==24.3.0
# via expense-bot (pyproject.toml)
boto3==1.20.32
# via expense-bot (pyproject.toml)
botocore==1.23.32
# via
# boto3
# expense-bot (pyproject.toml)
# s3transfer
build==1.0.3
# via pip-tools
cachetools==5.2.0
# via google-auth
certifi==2023.7.22
Expand All @@ -44,31 +33,23 @@ certifi==2023.7.22
charset-normalizer==2.0.12
# via requests
click==8.1.3
# via
# black
# pip-tools
# via black
dill==0.3.5.1
# via pylint
exceptiongroup==1.0.1
# via pytest
flake8==6.0.0
# via
# expense-bot (pyproject.toml)
# flake8-pyproject
# via flake8-pyproject
flake8-pyproject==1.2.2
# via expense-bot (pyproject.toml)
frozenlist==1.3.0
# via
# aiohttp
# aiosignal
google-api-core==2.8.1
# via google-api-python-client
google-api-python-client==2.50.0
# via
# expense-bot (pyproject.toml)
# google-api-python-client-stubs
# via google-api-python-client-stubs
google-api-python-client-stubs==1.11.0
# via expense-bot (pyproject.toml)
google-auth==2.7.0
# via
# google-api-core
Expand All @@ -86,8 +67,6 @@ idna==3.3
# via
# requests
# yarl
importlib-metadata==6.8.0
# via build
iniconfig==1.1.1
# via pytest
isort==5.10.1
Expand All @@ -109,20 +88,16 @@ multidict==6.0.2
# aiohttp
# yarl
mypy==1.0.1
# via expense-bot (pyproject.toml)
mypy-extensions==0.4.3
# via
# black
# mypy
packaging==24.0
# via
# black
# build
# pytest
pathspec==0.9.0
# via black
pip-tools==6.12.1
# via expense-bot (pyproject.toml)
platformdirs==2.5.2
# via
# black
Expand All @@ -148,21 +123,20 @@ pydantic-core==2.14.5
pyflakes==3.0.1
# via flake8
pylint==2.14.1
# via expense-bot (pyproject.toml)
pyparsing==3.0.9
# via httplib2
pyproject-hooks==1.0.0
# via build
pytest==7.2.0
# via expense-bot (pyproject.toml)
python-dateutil==2.8.2
# via botocore
requests==2.31.0
# via google-api-core
rsa==4.8
# via google-auth
ruff==0.3.5
s3transfer==0.5.2
# via boto3
setuptools==65.6.3
# via astroid
simplejson==3.17.2
# via awslambdaric
six==1.16.0
Expand All @@ -173,11 +147,9 @@ six==1.16.0
tomli==2.0.1
# via
# black
# build
# flake8-pyproject
# mypy
# pylint
# pyproject-hooks
# pytest
tomlkit==0.11.0
# via pylint
Expand All @@ -197,17 +169,8 @@ urllib3==1.26.18
# via
# botocore
# requests
wheel==0.42.0
# via
# expense-bot (pyproject.toml)
# pip-tools
wheel==0.43.0
wrapt==1.14.1
# via astroid
yarl==1.7.2
# via aiohttp
zipp==3.17.0
# via importlib-metadata

# The following packages are considered to be unsafe in a requirements file:
# pip
# setuptools
10 changes: 2 additions & 8 deletions reqs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
#
# This file is autogenerated by pip-compile with Python 3.9
# by the following command:
#
# pip-compile --output-file=reqs/requirements.txt --resolver=backtracking pyproject.toml
#
# This file was autogenerated by uv via the following command:
# uv pip compile pyproject.toml -o reqs/requirements.txt
aiofiles==23.2.1
# via aiogram
aiogram==3.2.0
# via expense-bot (pyproject.toml)
aiohttp==3.9.3
# via aiogram
aiosignal==1.2.0
Expand All @@ -33,7 +28,6 @@ frozenlist==1.3.0
google-api-core==2.8.1
# via google-api-python-client
google-api-python-client==2.50.0
# via expense-bot (pyproject.toml)
google-auth==2.7.0
# via
# google-api-core
Expand Down
3 changes: 1 addition & 2 deletions src/expense_bot/repositories/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ def __init__(self):
self._storage: _StorageType = defaultdict(list)

def get_all(self, *, dt: date) -> Iterable[ExpenseItem]:
vals = self._storage[dt] if dt in self._storage else []
return vals
return self._storage.get(dt) or []

def add(self, item: ExpenseItem, /, *, dt: date):
self._storage[dt].append(item)
Expand Down

0 comments on commit f1e5bf4

Please sign in to comment.