Skip to content

Commit 82c5ba4

Browse files
committed
Include neetcode shorts
Opt for UV instead of basic python
1 parent 175f893 commit 82c5ba4

19 files changed

Lines changed: 10120 additions & 2896 deletions

.coveragerc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[run]
2-
omit = tests/*,*/__init__.py
2+
omit = tests/*,*/__init__.py,scripts/*
33
branch = True
44

55
[report]

.github/workflows/check-style.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,19 @@ jobs:
1717
runs-on: '${{ matrix.os }}'
1818
steps:
1919
- uses: actions/checkout@v3
20-
- name: Set up Python ${{ matrix.python-version }}
21-
uses: actions/setup-python@v3
20+
- name: Set up UV
21+
uses: astral-sh/setup-uv@v3
2222
with:
23-
python-version: ${{ matrix.python-version }}
23+
version: "latest"
24+
- name: Set up Python ${{ matrix.python-version }}
25+
run: |
26+
uv python install ${{ matrix.python-version }}
2427
- name: Install dependencies
2528
run: |
26-
python -m pip install -e ".[dev]"
29+
uv sync --dev
2730
- name: Examine formatting with ruff
2831
run: |
29-
python -m ruff check ./leetcode_study_tool
32+
uv run ruff check ./leetcode_study_tool
3033
- name: Check formatting
3134
run: |
32-
python -m ruff format ./leetcode_study_tool --check
35+
uv run ruff format ./leetcode_study_tool --check

.github/workflows/publish.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,15 @@ jobs:
1515
id-token: write
1616
steps:
1717
- uses: actions/checkout@v4
18-
- name: Set up Python
19-
uses: actions/setup-python@v4
18+
- name: Set up UV
19+
uses: astral-sh/setup-uv@v3
2020
with:
21-
python-version: "3.x"
22-
- name: Install dependencies
21+
version: "latest"
22+
- name: Set up Python
2323
run: |
24-
python -m pip install --upgrade pip
25-
pip install setuptools wheel build
24+
uv python install 3.11
2625
- name: Build package
2726
run: |
28-
python -m build
27+
uv build
2928
- name: Publish package distributions to PyPI
3029
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/run-tests.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,19 @@ jobs:
1818
runs-on: ${{ matrix.os }}
1919
steps:
2020
- uses: actions/checkout@v3
21-
- name: Set up Python ${{ matrix.python-version }}
22-
uses: actions/setup-python@v3
21+
- name: Set up UV
22+
uses: astral-sh/setup-uv@v3
2323
with:
24-
python-version: ${{ matrix.python-version }}
24+
version: "latest"
25+
- name: Set up Python ${{ matrix.python-version }}
26+
run: |
27+
uv python install ${{ matrix.python-version }}
2528
- name: Install dependencies
2629
run: |
27-
python -m pip install -e ".[dev]"
30+
uv sync --dev
2831
- name: Type check with MyPy
2932
run: |
30-
python -m mypy ./leetcode_study_tool
33+
uv run mypy ./leetcode_study_tool
3134
- name: Test with pytest, ensuring 75% coverage
3235
run: |
33-
pip install pytest pytest-cov
34-
pytest tests/ --cov --cov-fail-under=75
36+
uv run pytest tests/ --cov --cov-fail-under=75

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.8

Makefile

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.PHONY: all format format-check test type-check sync install clean
2+
13
all:
24
@echo "Running make format"
35
$(MAKE) format
@@ -8,16 +10,25 @@ all:
810
@echo "Running make type-check"
911
$(MAKE) type-check
1012

13+
sync:
14+
uv sync --dev
15+
16+
install:
17+
uv sync
18+
19+
clean:
20+
rm -rf .venv
21+
1122
format:
12-
python -m ruff format ./leetcode_study_tool
13-
python -m ruff check ./leetcode_study_tool --fix
23+
uv run ruff format ./leetcode_study_tool
24+
uv run ruff check ./leetcode_study_tool --fix
1425

1526
format-check:
16-
python -m ruff format ./leetcode_study_tool --check
17-
python -m ruff check ./leetcode_study_tool
27+
uv run ruff format ./leetcode_study_tool --check
28+
uv run ruff check ./leetcode_study_tool
1829

1930
test:
20-
pytest tests/ --cov --cov-fail-under=85
31+
uv run pytest tests/ --cov --cov-fail-under=85
2132

2233
type-check:
23-
python -m mypy ./leetcode_study_tool
34+
uv run mypy ./leetcode_study_tool

README.md

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,66 @@ Here's an example template that highlights the solution code:
154154
{{ data.tags|map(attribute='slug')|join(' ') }}
155155
```
156156

157+
## 🛠 Development
158+
159+
For developers who want to contribute to this project, we use UV for dependency management:
160+
161+
### Setup with UV
162+
```shell
163+
# Install UV (if not already installed)
164+
curl -LsSf https://astral.sh/uv/install.sh | sh
165+
166+
# Clone and setup the project
167+
git clone https://github.com/johnsutor/leetcode-study-tool.git
168+
cd leetcode-study-tool
169+
uv sync --dev
170+
```
171+
172+
### Development Commands
173+
```shell
174+
# Format code
175+
make format
176+
177+
# Check formatting
178+
make format-check
179+
180+
# Run tests
181+
make test
182+
183+
# Type checking
184+
make type-check
185+
186+
# Sync dependencies
187+
make sync
188+
189+
# Install only main dependencies
190+
make install
191+
```
192+
193+
### Using UV Directly
194+
```shell
195+
# Add a new dependency
196+
uv add package-name
197+
198+
# Add a development dependency
199+
uv add --dev package-name
200+
201+
# Run any command in the project environment
202+
uv run python leetcode_study_tool/cli.py --help
203+
204+
# Update lockfile
205+
uv lock
206+
```
207+
157208
## 🛣 Roadmap
158209
- [X] Use TQDM to show card generation progress
159210
- [X] Add support for exporting to an excel sheet
160211
- [X] Add support for showing neetcode solutions on the back of the card as a
161212
- [X] Add support for getting the difficulty of questions
162213
- [X] Add support for Jinja templating formatters
163214
- [X] Add support for including NeetCode solution code
164-
- [ ] Add NeetCode shorts
215+
- [X] Migrate to UV for faster dependency management
216+
- [X] Add NeetCode shorts
165217
- [ ] Add support for fetching premium questions via authentification
166218
- [ ] Add support for importing cards into Quizlet
167219
- [ ] Add support for fetching questions by topic or tag

leetcode_study_tool/formatters.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def format_excel(url: str, slug: str, data: dict) -> List[Union[str, date]]:
148148
The Excel problem for the given URL and data. The problem
149149
is formatted as a list of strings, where each string is a
150150
column in the Excel file. This row will have the ordering:
151-
[id, title, url, date attempted, tags, neetcode, solutions, companies]
151+
[id, title, difficulty, url, date attempted, tags, video_url, short_url, solutions, companies]
152152
"""
153153
row = []
154154
row.append(data["id"])
@@ -158,10 +158,16 @@ def format_excel(url: str, slug: str, data: dict) -> List[Union[str, date]]:
158158
row.append(date.today())
159159
row.append(", ".join([tag["name"] for tag in data["tags"]]))
160160
if str(data["id"]) in LEETCODE_TO_NEETCODE:
161-
neetcode = LEETCODE_TO_NEETCODE[str(data["id"])]
162-
row.append(neetcode["url"])
161+
neetcode_data = LEETCODE_TO_NEETCODE[str(data["id"])]
162+
# Add regular video URL
163+
video_url = neetcode_data.get("video", {}).get("url", "")
164+
row.append(video_url)
165+
# Add shorts URL in new column
166+
short_url = neetcode_data.get("short", {}).get("url", "")
167+
row.append(short_url)
163168
else:
164-
row.append("")
169+
row.append("") # No regular video
170+
row.append("") # No short
165171
row.append(data.get("neetcode_solution", ""))
166172
row.append(
167173
"\n".join(

0 commit comments

Comments
 (0)