Set up python environment for easier development

This commit is contained in:
Johan Sandoval
2026-07-21 19:01:11 -05:00
parent 4f15387a70
commit 78725a4eed
7 changed files with 72 additions and 3 deletions
+1
View File
@@ -0,0 +1 @@
use flake
+5
View File
@@ -0,0 +1,5 @@
.direnv/
__pycache__/
.pytest_cache/
.ruff_cache/
result
-3
View File
@@ -1,3 +0,0 @@
class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
Generated
+27
View File
@@ -0,0 +1,27 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1784497964,
"narHash": "sha256-vlHUuqAcbcH2RKmHbPiuQzbv1pnzzavXnI62RD0bqCU=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "241313f4e8e508cb9b13278c2b0fa25b9ca27163",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}
+18
View File
@@ -0,0 +1,18 @@
{
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
outputs = { self, nixpkgs }:
let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
in {
devShells.${system}.default = pkgs.mkShell {
packages = with pkgs; [
python313
ruff # lint + format
basedpyright # LSP / type checking
python313Packages.pytest
entr
];
};
};
}
Executable
+12
View File
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
d="problems/$1"; mkdir -p "$d"
cat > "$d/solution.py" <<'EOF'
class Solution:
def solve(self):
pass
EOF
cat > "$d/solution_test.py" <<'EOF'
from solution import Solution
def test_solve():
assert Solution().solve() is None
EOF
+9
View File
@@ -0,0 +1,9 @@
[tool.ruff]
line-length = 100
[tool.ruff.lint]
select = ["E", "F", "I", "UP", "B", "SIM"]
[tool.pytest.ini_options]
testpaths = ["."]
python_files = ["*_test.py"]