Skip to content

Commit d1e0b2b

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 0fe5035 + 15eb0ed commit d1e0b2b

431 files changed

Lines changed: 439572 additions & 22621 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.circleci/config.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ orbs:
55

66
references:
77
python_images: &python_images
8-
- "cimg/python:3.9"
98
- "cimg/python:3.10"
109
- "cimg/python:3.11"
1110
- "cimg/python:3.12"
@@ -35,10 +34,13 @@ jobs:
3534
- snyk/scan
3635
- run:
3736
name: run tests
38-
command: poetry run pytest
39-
- run:
40-
name: run flake8
41-
command: poetry run flake8
37+
command: poetry run pytest tests/unit
38+
- run:
39+
name: run tests
40+
command: poetry run pytest tests/integration -m "vcr"
41+
- run:
42+
name: run ruff
43+
command: poetry run ruff check && poetry run ruff format --check
4244

4345
release:
4446
docker:

.devcontainer/Dockerfile

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Specify the Python version and base OS for the container
2+
# VARIANT allows customization of Python version (default: 3.10 on Debian Bullseye)
3+
ARG VARIANT="3.10-bullseye"
4+
5+
# Use Microsoft's official Python dev container as the base image
6+
FROM mcr.microsoft.com/devcontainers/python:1-${VARIANT}
7+
8+
# Install system packages as root user before switching to vscode
9+
# - ODBC drivers for SQL Server connectivity
10+
# - GitHub CLI for PR management and git workflows
11+
RUN apt-get update && apt-get install -y \
12+
unixodbc \
13+
unixodbc-dev \
14+
&& curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | tee /usr/share/keyrings/githubcli-archive-keyring.gpg > /dev/null \
15+
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
16+
&& apt-get update \
17+
&& apt-get install -y gh \
18+
&& apt-get clean \
19+
&& rm -rf /var/lib/apt/lists/*
20+
21+
# Switch from root to the vscode user for security and proper file permissions
22+
# The vscode user is pre-configured in the base image with development tools
23+
USER vscode
24+
25+
# Download and install Poetry package manager for the vscode user
26+
# Poetry manages Python dependencies and virtual environments
27+
RUN curl -sSL https://install.python-poetry.org -o /tmp/install-poetry.py \
28+
&& python3 /tmp/install-poetry.py \
29+
&& rm /tmp/install-poetry.py
30+
31+
# Add Poetry's installation directory to the system PATH
32+
# This allows the 'poetry' command to be run from anywhere
33+
ENV PATH="/home/vscode/.local/bin:$PATH"
34+
35+
# Configure Poetry to create virtual environments inside the project directory
36+
# This creates a .venv folder in your project root instead of Poetry's global cache
37+
# This setting acts as a "gate" - it ensures proper environment setup before shells can run
38+
# Set cache directory to /tmp to enable fast package downloads during build
39+
# while preventing cache bloat in the final Docker image
40+
RUN poetry config virtualenvs.in-project true \
41+
&& poetry config cache-dir /tmp/poetry_cache
42+
43+
# Set the working directory where your project files will be mounted
44+
# This is where VS Code will open and where your code will live
45+
WORKDIR /workspace

.devcontainer/devcontainer.json

Lines changed: 67 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,72 @@
11
{
2-
"containerEnv": {
3-
"PYTHON_VERSION": "3.11"
4-
},
5-
"features": {
6-
"ghcr.io/devcontainers/features/python:latest": {},
7-
"ghcr.io/devcontainers-contrib/features/poetry:2": {}
8-
},
9-
"image": "mcr.microsoft.com/devcontainers/base:debian-11",
10-
"name": "nba_api",
11-
"postCreateCommand": "bash .devcontainer/postCreateCommand.sh",
12-
"remoteEnv": {
13-
"PYTHONUTF8": "1"
14-
},
2+
// Display name for this dev container configuration
3+
"name": "NBA API",
4+
5+
// Build configuration for the container
6+
"build": {
7+
// Path to the Dockerfile relative to the build context
8+
"dockerfile": "Dockerfile",
9+
// Build context directory - ".." means parent directory of .devcontainer folder
10+
// This allows Docker to access project files outside the .devcontainer directory
11+
"context": ".."
12+
},
13+
14+
// VS Code specific customizations
1515
"customizations": {
1616
"vscode": {
17+
18+
// Extensions to install automatically in the container
19+
// These provide Python development tools, linting, and formatting
1720
"extensions": [
18-
"ms-python.black-formatter",
19-
"ms-python.flake8",
20-
"ms-python.python",
21-
"ms-python.vscode-pylance",
22-
"ms-toolsai.jupyter",
23-
"ms-toolsai.jupyter-keymap",
24-
"ms-toolsai.jupyter-renderers",
25-
"ms-toolsai.vscode-jupyter-powertoys"
26-
]
27-
}
28-
}
21+
"ms-python.black-formatter",
22+
"ms-python.flake8",
23+
"ms-python.isort",
24+
"ms-python.pylint",
25+
"ms-python.python",
26+
"ms-python.vscode-pylance",
27+
"ms-toolsai.jupyter",
28+
"ms-toolsai.jupyter-keymap",
29+
"ms-toolsai.jupyter-renderers",
30+
"ms-toolsai.vscode-jupyter-powertoys",
31+
"tamasfe.even-better-toml"
32+
],
33+
34+
// VS Code settings to apply in the container
35+
"settings": {
36+
37+
// Enable Python linting globally across all Python files
38+
// This provides real-time error detection and code quality feedback
39+
"python.linting.enabled": true,
40+
41+
// Enable pylint as the primary linting tool
42+
// Pylint provides comprehensive code analysis and style checking
43+
"python.linting.pylintEnabled": true,
44+
45+
// Automatically format Python files when saving
46+
// This ensures consistent code style across the project
47+
"editor.formatOnSave": true,
48+
49+
// Use Black as the Python code formatter
50+
// Black is an opinionated formatter that enforces consistent style
51+
"python.formatting.provider": "black",
52+
53+
// Set bash as the default terminal shell in Linux containers
54+
// This ensures consistent shell behavior across different environments
55+
"terminal.integrated.defaultProfile.linux": "bash"
56+
}
57+
}
58+
},
59+
60+
// Ports to forward from container to host (empty array = no ports forwarded)
61+
// Add port numbers here if your application serves web content (e.g., [8000, 3000])
62+
"forwardPorts": [],
63+
64+
// User to connect as when attaching to the container
65+
// "vscode" user has proper permissions and development tools pre-configured
66+
"remoteUser": "vscode",
67+
68+
// Command to run after the container is created and VS Code connects
69+
// This executes the post-create script that sets up Poetry and dependencies
70+
// Runs only once when the container is first created, not on every restart
71+
"postCreateCommand": "bash .devcontainer/post-create-command.sh"
2972
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
pip install --upgrade pip
2+
poetry install
3+
# Activate poetry environment
4+
source $(poetry env info --path)/bin/activate
5+
6+
# Update PYTHONPATH to include the virtual environment's Python interpreter
7+
echo "export PYTHON_PATH=$(poetry env info --path)/bin/python" >> ~/.bashrc
8+
#!/bin/bash
9+
# Shebang: tells the system to execute this script using bash
10+
11+
# Exit immediately if any command fails (prevents partial setup)
12+
# This ensures the development environment is either fully set up or fails clearly
13+
set -e
14+
15+
# Display status message to user during container setup
16+
echo "Setting up development environment..."
17+
18+
# Install all dependencies from pyproject.toml and poetry.lock
19+
# --with linting,test includes optional dependency groups for development tools
20+
# This creates the .venv directory and installs packages inside it
21+
poetry install
22+
23+
# Configure shell activation for all future terminal sessions
24+
# This adds a command to .bashrc that automatically activates the Poetry environment
25+
# The '2>/dev/null || true' suppresses errors if Poetry environment doesn't exist yet
26+
echo 'eval "$(poetry env activate)" 2>/dev/null || true' >> ~/.bashrc
27+
28+
# Display completion message to user
29+
echo "Setup complete! Poetry environment activated."

.devcontainer/postCreateCommand.sh

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

.flake8

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

.github/CODEOWNERS

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# CODEOWNERS file for nba_api
2+
# This file defines who will be automatically requested for review
3+
# when someone opens a pull request.
4+
#
5+
# More information: https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners
6+
7+
# Default owners for everything in the repository
8+
* @swar

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,7 @@ nba_api/library/debug/
131131
.history/
132132

133133
# Built Visual Studio Code Extensions
134-
*.vsix
134+
*.vsix
135+
136+
# Git worktrees
137+
.worktrees/

.pre-commit-config.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
repos:
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
rev: v0.15.2
4+
hooks:
5+
- id: ruff # lint + auto-fix
6+
args: [--fix]
7+
- id: ruff-format # format

.vscode/settings.json

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
{
22
"editor.formatOnSave": true,
3-
"flake8.args": [
4-
"--config=.flake8"
5-
],
6-
"python.formatting.provider": "black",
7-
"python.formatting.blackArgs": [
8-
"--line-length",
9-
"88"
10-
],
3+
"[python]": {
4+
"editor.defaultFormatter": "charliermarsh.ruff",
5+
"editor.codeActionsOnSave": {
6+
"source.fixAll.ruff": "explicit",
7+
"source.organizeImports.ruff": "explicit"
8+
}
9+
},
1110
"python.analysis.diagnosticSeverityOverrides": {
1211
"reportUnboundVariable": "information",
1312
"reportImplicitStringConcatenation": "warning",
@@ -18,4 +17,4 @@
1817
],
1918
"python.testing.unittestEnabled": false,
2019
"python.testing.pytestEnabled": true
21-
}
20+
}

0 commit comments

Comments
 (0)