Skip to content

Commit 16b1f01

Browse files
committed
fix py formatting
1 parent 46208ed commit 16b1f01

12 files changed

Lines changed: 30 additions & 25 deletions

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
target/
2-
venv/
32
.direnv/
43
.vscode/
54
.envrc

flake.nix

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,25 @@
1010
system = "x86_64-linux";
1111
pkgs = import nixpkgs { inherit system; };
1212
python = pkgs.python312;
13-
venv_dir = "./venv/";
1413
in
1514
{
1615
devShells.${system}.default = pkgs.mkShell {
1716
packages = with pkgs; [
17+
# Rust deps
1818
rustc
1919
cargo
2020
clippy
2121
rust-analyzer
2222
rustfmt
23+
24+
# Python + Deps
2325
python
24-
python.pkgs.venvShellHook
26+
python.pkgs.typer
27+
python.pkgs.browser-cookie3
28+
python.pkgs.natsort
29+
python.pkgs.black
30+
python.pkgs.isort
2531
];
26-
venvDir = venv_dir;
27-
postShellHook = ''
28-
SENTINEL="${venv_dir}/.installed"
29-
REQUIREMENTS="requirements.txt"
30-
31-
if [ ! -f "$SENTINEL" ] || [ "$REQUIREMENTS" -nt "$SENTINEL" ]; then
32-
pip install --upgrade pip
33-
pip install -r "$REQUIREMENTS"
34-
touch "$SENTINEL"
35-
fi
36-
'';
3732
};
3833
};
3934
}

scripts/format.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@
22

33
find src | grep \.rs$ | xargs rustfmt
44

5-
find src | grep \.cpp$ | xargs clang-format -i
5+
find src | grep \.cpp$ | xargs clang-format -i
6+
7+
python3 -m isort --profile black .
8+
python3 -m black .

scripts/sync_config.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#!/usr/bin/env python3
22

3-
import browser_cookie3 # type: ignore
3+
import json
44
import os
55
import re
6-
import json
7-
import typer
86

7+
import browser_cookie3 # type: ignore
8+
import typer
99

1010
LEETCODE_DOMAIN_NAME = "leetcode.com"
1111

@@ -34,7 +34,7 @@
3434
EXISTING_LANGUAGE_REGEX = re.compile(r"^lang = \"(\w+)\"$", re.MULTILINE)
3535

3636

37-
def main(language: str) -> None:
37+
def main(language: str | None = None) -> None:
3838
cj = browser_cookie3.chrome(domain_name=LEETCODE_DOMAIN_NAME)
3939
cookies = {c.name: c.value for c in cj}
4040

scripts/update_mods.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#!/usr/bin/env python3
22

3+
import re
34
from pathlib import Path
5+
46
from natsort import natsorted
5-
import re
67

78
SOLUTION_DIR = "./src/rust_solutions/"
89
MOD_PATH = "./src/rust_solutions/mod.rs"

src/python_solutions/2149_rearrange-array-elements-by-sign.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from common import *
22

3-
# start_submission
3+
4+
# start_submission
45
class Solution:
56
def rearrangeArray(self, nums: List[int]) -> List[int]:
67
n = len(nums)
@@ -16,7 +17,8 @@ def rearrangeArray(self, nums: List[int]) -> List[int]:
1617
else:
1718
ans[2 * odd_i + 1] = n
1819
odd_i += 1
19-
20+
2021
return ans
21-
22-
# end_submission
22+
23+
24+
# end_submission

src/python_solutions/2179_count-good-triplets-in-an-array.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from common import *
22

3+
34
# start_submission
45
class STree:
56
def __init__(self, v):

src/python_solutions/2786_visit-array-positions-to-maximize-score.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from common import *
22

3+
34
# start_submission
45
class Solution:
56
def maxScore(self, nums: List[int], x: int) -> int:

src/python_solutions/3027_find-the-number-of-ways-to-place-people-ii.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from common import *
22

3+
34
# start_submission
45
class Solution:
56
def maximumPoints(self, enemyEnergies: List[int], currentEnergy: int) -> int:

src/python_solutions/3100_water-bottles-ii.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from common import *
22

3+
34
# start_submission
45
class Solution:
56
def maxBottlesDrunk(self, numBottles: int, numExchange: int) -> int:

0 commit comments

Comments
 (0)