git-pandas 1.2.0__tar.gz → 2.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- git_pandas-2.2.0/.cursor/rules/project_overview.mdc +228 -0
- git_pandas-2.2.0/.cursor/rules/pytest_standards.mdc +48 -0
- git_pandas-2.2.0/.cursor/rules/python_standards.mdc +68 -0
- git_pandas-2.2.0/.cursor/rules/sphinx_docs_standards.mdc +62 -0
- git_pandas-2.2.0/.cursor/rules/testing.mdc +53 -0
- git_pandas-2.2.0/.github/ISSUE_TEMPLATE.md +17 -0
- git_pandas-2.2.0/.github/PULL_REQUEST_TEMPLATE.md +7 -0
- git_pandas-2.2.0/.github/workflows/docs.yml +40 -0
- git_pandas-2.2.0/.github/workflows/pypi-publish.yml +55 -0
- git_pandas-2.2.0/.github/workflows/test-docs-build.yml +29 -0
- git_pandas-2.2.0/.github/workflows/test-suite.yml +45 -0
- git_pandas-2.2.0/.gitignore +73 -0
- git_pandas-2.2.0/CHANGELOG.md +94 -0
- git_pandas-2.2.0/CONTRIBUTING.md +58 -0
- git_pandas-2.2.0/LICENSE.md +12 -0
- git_pandas-2.2.0/Makefile +97 -0
- git_pandas-2.2.0/PKG-INFO +149 -0
- git_pandas-2.2.0/README.md +111 -0
- git_pandas-2.2.0/docs/Makefile +192 -0
- git_pandas-2.2.0/docs/make.bat +263 -0
- git_pandas-2.2.0/docs/requirements.txt +4 -0
- git_pandas-2.2.0/docs/source/cache.rst +121 -0
- git_pandas-2.2.0/docs/source/conf.py +364 -0
- git_pandas-2.2.0/docs/source/contributors.rst +123 -0
- git_pandas-2.2.0/docs/source/index.rst +114 -0
- git_pandas-2.2.0/docs/source/project.rst +124 -0
- git_pandas-2.2.0/docs/source/repository.rst +119 -0
- git_pandas-2.2.0/docs/source/usecases.rst +196 -0
- git_pandas-2.2.0/examples/__init__.py +1 -0
- git_pandas-2.2.0/examples/attributes.py +63 -0
- git_pandas-2.2.0/examples/bus_analysis.py +47 -0
- git_pandas-2.2.0/examples/cloud_repo.py +10 -0
- git_pandas-2.2.0/examples/commit_history.py +112 -0
- git_pandas-2.2.0/examples/cumulative_blame.py +50 -0
- git_pandas-2.2.0/examples/definitions.py +3 -0
- git_pandas-2.2.0/examples/file_change_rates.py +11 -0
- git_pandas-2.2.0/examples/hours_estimate.py +54 -0
- git_pandas-2.2.0/examples/img/cumulative_blame.png +0 -0
- git_pandas-2.2.0/examples/img/cumulative_project_blame.png +0 -0
- git_pandas-2.2.0/examples/img/githubblame.png +0 -0
- git_pandas-2.2.0/examples/img/lifeline.png +0 -0
- git_pandas-2.2.0/examples/img/stravalib_cumulative_blame.png +0 -0
- git_pandas-2.2.0/examples/lifeline.py +72 -0
- git_pandas-2.2.0/examples/parallel_blame.py +64 -0
- git_pandas-2.2.0/examples/project_blame.py +11 -0
- git_pandas-2.2.0/examples/punchcard.py +16 -0
- git_pandas-2.2.0/examples/repo_file_detail.py +11 -0
- git_pandas-2.2.0/gitpandas/__init__.py +6 -0
- git_pandas-2.2.0/gitpandas/cache.py +157 -0
- git_pandas-2.2.0/gitpandas/project.py +1179 -0
- git_pandas-2.2.0/gitpandas/repository.py +1690 -0
- {git-pandas-1.2.0 → git_pandas-2.2.0}/gitpandas/utilities/__init__.py +9 -1
- git_pandas-2.2.0/gitpandas/utilities/check_api.py +40 -0
- git_pandas-2.2.0/gitpandas/utilities/plotting.py +217 -0
- git_pandas-2.2.0/img/cumulative_blame.png +0 -0
- git_pandas-2.2.0/img/lifeline.png +0 -0
- git_pandas-2.2.0/img/punchcard.png +0 -0
- git_pandas-2.2.0/pyproject.toml +91 -0
- git_pandas-2.2.0/tests/__init__.py +5 -0
- git_pandas-2.2.0/tests/conftest.py +12 -0
- git_pandas-2.2.0/tests/test_Project/__init__.py +5 -0
- git_pandas-2.2.0/tests/test_Project/test_advanced.py +232 -0
- git_pandas-2.2.0/tests/test_Project/test_properties.py +229 -0
- git_pandas-2.2.0/tests/test_Repository/__init__.py +5 -0
- git_pandas-2.2.0/tests/test_Repository/test_advanced.py +258 -0
- git_pandas-2.2.0/tests/test_Repository/test_bus_factor.py +143 -0
- git_pandas-2.2.0/tests/test_Repository/test_file_detail.py +190 -0
- git_pandas-2.2.0/tests/test_Repository/test_properties.py +152 -0
- git_pandas-2.2.0/tests/test_Repository/test_punchcard.py +180 -0
- git_pandas-2.2.0/tests/test_cache.py +394 -0
- git_pandas-2.2.0/tests/test_examples.py +61 -0
- git_pandas-2.2.0/tests/test_utilities/test_check_api.py +63 -0
- git_pandas-2.2.0/tests/test_utilities/test_init.py +7 -0
- git_pandas-2.2.0/tests/test_utilities/test_plotting.py +375 -0
- git-pandas-1.2.0/MANIFEST.in +0 -2
- git-pandas-1.2.0/PKG-INFO +0 -82
- git-pandas-1.2.0/README.md +0 -68
- git-pandas-1.2.0/examples/__init__.py +0 -1
- git-pandas-1.2.0/examples/attributes.py +0 -58
- git-pandas-1.2.0/examples/bus_analysis.py +0 -21
- git-pandas-1.2.0/examples/cloud_repo.py +0 -10
- git-pandas-1.2.0/examples/commit_history.py +0 -90
- git-pandas-1.2.0/examples/coverage_data.py +0 -1
- git-pandas-1.2.0/examples/cumulative_blame.py +0 -10
- git-pandas-1.2.0/examples/file_change_rates.py +0 -10
- git-pandas-1.2.0/examples/hours_estimate.py +0 -22
- git-pandas-1.2.0/examples/lifeline.py +0 -61
- git-pandas-1.2.0/examples/project_blame.py +0 -11
- git-pandas-1.2.0/examples/punchcard.py +0 -19
- git-pandas-1.2.0/examples/repo_file_detail.py +0 -11
- git-pandas-1.2.0/git_pandas.egg-info/PKG-INFO +0 -82
- git-pandas-1.2.0/git_pandas.egg-info/SOURCES.txt +0 -29
- git-pandas-1.2.0/git_pandas.egg-info/dependency_links.txt +0 -1
- git-pandas-1.2.0/git_pandas.egg-info/requires.txt +0 -3
- git-pandas-1.2.0/git_pandas.egg-info/top_level.txt +0 -2
- git-pandas-1.2.0/gitpandas/__init__.py +0 -11
- git-pandas-1.2.0/gitpandas/project.py +0 -734
- git-pandas-1.2.0/gitpandas/repository.py +0 -871
- git-pandas-1.2.0/gitpandas/utilities/check_api.py +0 -75
- git-pandas-1.2.0/gitpandas/utilities/plotting.py +0 -86
- git-pandas-1.2.0/requirements.txt +0 -5
- git-pandas-1.2.0/setup.cfg +0 -11
- git-pandas-1.2.0/setup.py +0 -36
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Overview of the gitpandas project
|
|
3
|
+
globs:
|
|
4
|
+
alwaysApply: false
|
|
5
|
+
---
|
|
6
|
+
I'll do a thorough analysis of the gitpandas library to help new developers understand it. Let me start by exploring the codebase to get a comprehensive understanding.
|
|
7
|
+
|
|
8
|
+
Ran tool
|
|
9
|
+
Let's first look at the README to get an overview of the project:
|
|
10
|
+
|
|
11
|
+
Read file: README.md
|
|
12
|
+
Now let's look at the main module structure:
|
|
13
|
+
|
|
14
|
+
Ran tool
|
|
15
|
+
Let's check the __init__.py file to understand the main components:
|
|
16
|
+
|
|
17
|
+
Read file: gitpandas/__init__.py
|
|
18
|
+
Now let's look at the repository.py file, which seems to be one of the main components:
|
|
19
|
+
|
|
20
|
+
Read file: gitpandas/repository.py
|
|
21
|
+
Let's also look at the project.py file to understand the ProjectDirectory class:
|
|
22
|
+
|
|
23
|
+
Read file: gitpandas/project.py
|
|
24
|
+
Let's also check the cache.py file to understand the caching mechanism:
|
|
25
|
+
|
|
26
|
+
Read file: gitpandas/cache.py
|
|
27
|
+
Let's check the utilities directory to understand what helper functions are available:
|
|
28
|
+
|
|
29
|
+
Ran tool
|
|
30
|
+
Let's look at the utilities/__init__.py file:
|
|
31
|
+
|
|
32
|
+
Read file: gitpandas/utilities/__init__.py
|
|
33
|
+
Let's look at the plotting utilities:
|
|
34
|
+
|
|
35
|
+
Read file: gitpandas/utilities/plotting.py
|
|
36
|
+
Let's check the examples directory to see how the library is used:
|
|
37
|
+
|
|
38
|
+
Ran tool
|
|
39
|
+
Let's look at a couple of example files to understand how the library is used:
|
|
40
|
+
|
|
41
|
+
Read file: examples/commit_history.py
|
|
42
|
+
|
|
43
|
+
Read file: examples/bus_analysis.py
|
|
44
|
+
|
|
45
|
+
Read file: examples/cumulative_blame.py
|
|
46
|
+
Let's check the pyproject.toml file to understand the project dependencies and metadata:
|
|
47
|
+
|
|
48
|
+
Read file: pyproject.toml
|
|
49
|
+
Based on my thorough analysis of the gitpandas library, here's a comprehensive overview for new developers:
|
|
50
|
+
|
|
51
|
+
# GitPandas: A Comprehensive Overview
|
|
52
|
+
|
|
53
|
+
## What is GitPandas?
|
|
54
|
+
|
|
55
|
+
GitPandas is a Python library that provides a set of wrappers around GitPython for creating pandas DataFrames from git repository data. It enables data-driven analysis of git repositories, allowing developers and data scientists to extract meaningful insights from their codebase's history and structure.
|
|
56
|
+
|
|
57
|
+
## Core Components
|
|
58
|
+
|
|
59
|
+
GitPandas is built around two primary objects:
|
|
60
|
+
|
|
61
|
+
1. **Repository**: Represents a single git repository and provides methods to analyze it.
|
|
62
|
+
2. **ProjectDirectory**: Represents a directory containing multiple git repositories, allowing for aggregated analysis across all repositories.
|
|
63
|
+
3. **GitHubProfile**: A specialized ProjectDirectory that analyzes all repositories owned by a GitHub user.
|
|
64
|
+
|
|
65
|
+
## Key Features
|
|
66
|
+
|
|
67
|
+
### Repository Analysis
|
|
68
|
+
- **Commit History**: Extract detailed commit history with filtering by file extensions and directories
|
|
69
|
+
- **File Change History**: Track how files have changed over time
|
|
70
|
+
- **Blame Analysis**: Determine who wrote each line of code in the repository
|
|
71
|
+
- **Branch and Tag Information**: Extract metadata about branches and tags
|
|
72
|
+
- **Bus Factor Analysis**: Estimate the project's "bus factor" (risk if key contributors leave)
|
|
73
|
+
- **Cumulative Blame**: Track how code ownership changes over time
|
|
74
|
+
- **Punchcard Analysis**: Visualize when code is written (day/hour patterns)
|
|
75
|
+
- **Hours Estimation**: Estimate time spent on the project by contributors
|
|
76
|
+
|
|
77
|
+
### Project Directory Analysis
|
|
78
|
+
- Aggregate all the above analyses across multiple repositories
|
|
79
|
+
- Compare metrics across repositories
|
|
80
|
+
- Generate project-wide statistics and visualizations
|
|
81
|
+
|
|
82
|
+
### Visualization Utilities
|
|
83
|
+
- Plot cumulative blame over time
|
|
84
|
+
- Create punchcard visualizations of commit patterns
|
|
85
|
+
|
|
86
|
+
### Caching System
|
|
87
|
+
- In-memory caching via `EphemeralCache`
|
|
88
|
+
- Redis-based caching via `RedisDFCache`
|
|
89
|
+
- Decorator-based caching system for expensive operations
|
|
90
|
+
|
|
91
|
+
## Core Concepts
|
|
92
|
+
|
|
93
|
+
### Data Representation
|
|
94
|
+
All data in GitPandas is represented as pandas DataFrames, making it easy to:
|
|
95
|
+
- Filter and transform the data
|
|
96
|
+
- Visualize results
|
|
97
|
+
- Export to various formats
|
|
98
|
+
- Integrate with other data analysis workflows
|
|
99
|
+
|
|
100
|
+
### Filtering Mechanisms
|
|
101
|
+
GitPandas provides consistent filtering options across most methods:
|
|
102
|
+
- `ignore_globs`: Glob patterns for files to exclude (e.g., `['tests/*', 'docs/*']`)
|
|
103
|
+
- `include_globs`: Glob patterns for files to include (e.g., `['*.py', '*.js']`)
|
|
104
|
+
- `limit`: Limit the number of commits to analyze
|
|
105
|
+
- `days`: Limit analysis to commits within a certain number of days
|
|
106
|
+
- `branch`: Specify which branch to analyze
|
|
107
|
+
|
|
108
|
+
### Caching
|
|
109
|
+
GitPandas implements a flexible caching system to improve performance:
|
|
110
|
+
- The `multicache` decorator allows caching results of expensive operations
|
|
111
|
+
- Cache backends can be swapped (memory or Redis)
|
|
112
|
+
- Cache keys are generated based on repository name and method parameters
|
|
113
|
+
|
|
114
|
+
## Usage Patterns
|
|
115
|
+
|
|
116
|
+
### Single Repository Analysis
|
|
117
|
+
```python
|
|
118
|
+
from gitpandas import Repository
|
|
119
|
+
|
|
120
|
+
# Create a Repository object
|
|
121
|
+
repo = Repository(working_dir='/path/to/repo')
|
|
122
|
+
|
|
123
|
+
# Get commit history
|
|
124
|
+
commit_history = repo.commit_history(branch='master', include_globs=['*.py'])
|
|
125
|
+
|
|
126
|
+
# Analyze blame
|
|
127
|
+
blame = repo.blame(committer=True)
|
|
128
|
+
|
|
129
|
+
# Estimate bus factor
|
|
130
|
+
bus_factor = repo.bus_factor()
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Multi-Repository Analysis
|
|
134
|
+
```python
|
|
135
|
+
from gitpandas import ProjectDirectory
|
|
136
|
+
|
|
137
|
+
# Create a ProjectDirectory object
|
|
138
|
+
project = ProjectDirectory(working_dir='/path/to/project')
|
|
139
|
+
|
|
140
|
+
# Get aggregated commit history
|
|
141
|
+
commit_history = project.commit_history(branch='master')
|
|
142
|
+
|
|
143
|
+
# Get aggregated blame
|
|
144
|
+
blame = project.blame()
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### GitHub Profile Analysis
|
|
148
|
+
```python
|
|
149
|
+
from gitpandas import GitHubProfile
|
|
150
|
+
|
|
151
|
+
# Analyze a GitHub user's repositories
|
|
152
|
+
profile = GitHubProfile(username='username')
|
|
153
|
+
|
|
154
|
+
# Get repository information
|
|
155
|
+
repo_info = profile.repo_information()
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Visualization
|
|
159
|
+
```python
|
|
160
|
+
from gitpandas import Repository
|
|
161
|
+
from gitpandas.utilities.plotting import plot_cumulative_blame
|
|
162
|
+
|
|
163
|
+
repo = Repository(working_dir='/path/to/repo')
|
|
164
|
+
blame = repo.cumulative_blame(branch='master')
|
|
165
|
+
plot_cumulative_blame(blame)
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Technical Implementation Details
|
|
169
|
+
|
|
170
|
+
### Git Integration
|
|
171
|
+
- Uses GitPython under the hood to interact with git repositories
|
|
172
|
+
- Can work with local repositories or clone remote ones
|
|
173
|
+
- Handles bare repositories appropriately
|
|
174
|
+
|
|
175
|
+
### Performance Considerations
|
|
176
|
+
- Caching system for expensive operations
|
|
177
|
+
- Optional parallel processing for certain operations (requires joblib)
|
|
178
|
+
- Filtering mechanisms to limit analysis scope
|
|
179
|
+
|
|
180
|
+
### Data Processing
|
|
181
|
+
- Heavy use of pandas for data manipulation and aggregation
|
|
182
|
+
- Consistent DataFrame structures across different analyses
|
|
183
|
+
- Time series analysis capabilities
|
|
184
|
+
|
|
185
|
+
## Development Conventions
|
|
186
|
+
|
|
187
|
+
### Code Organization
|
|
188
|
+
- Core classes in separate modules (`repository.py`, `project.py`)
|
|
189
|
+
- Utility functions in the `utilities` package
|
|
190
|
+
- Caching mechanisms in `cache.py`
|
|
191
|
+
|
|
192
|
+
### Error Handling
|
|
193
|
+
- Graceful handling of missing repositories
|
|
194
|
+
- Proper cleanup of temporary repositories
|
|
195
|
+
- Appropriate warnings for deprecated functionality
|
|
196
|
+
|
|
197
|
+
### Dependencies
|
|
198
|
+
- Core dependencies: GitPython, pandas, numpy
|
|
199
|
+
- Optional dependencies: matplotlib (for plotting), redis (for Redis caching), joblib (for parallel processing)
|
|
200
|
+
|
|
201
|
+
## Practical Applications
|
|
202
|
+
|
|
203
|
+
GitPandas can be used for:
|
|
204
|
+
1. **Project Management**: Track contributor activity and estimate effort
|
|
205
|
+
2. **Code Quality Analysis**: Identify areas with high churn or single-owner code
|
|
206
|
+
3. **Team Dynamics**: Understand how team members collaborate and contribute
|
|
207
|
+
4. **Historical Analysis**: Track how a project evolves over time
|
|
208
|
+
5. **Risk Assessment**: Identify bus factor and knowledge silos
|
|
209
|
+
6. **Performance Metrics**: Generate developer and team performance metrics
|
|
210
|
+
|
|
211
|
+
## Extending GitPandas
|
|
212
|
+
|
|
213
|
+
Developers can extend GitPandas by:
|
|
214
|
+
1. Adding new analysis methods to the Repository or ProjectDirectory classes
|
|
215
|
+
2. Creating new visualization utilities
|
|
216
|
+
3. Implementing additional caching backends
|
|
217
|
+
4. Building higher-level abstractions for specific use cases
|
|
218
|
+
|
|
219
|
+
## Best Practices
|
|
220
|
+
|
|
221
|
+
When working with GitPandas:
|
|
222
|
+
1. Use appropriate filtering to limit analysis scope for large repositories
|
|
223
|
+
2. Implement caching for repeated analyses
|
|
224
|
+
3. Consider using parallel processing for intensive operations
|
|
225
|
+
4. Combine multiple analyses for comprehensive insights
|
|
226
|
+
5. Visualize results for easier interpretation
|
|
227
|
+
|
|
228
|
+
This overview should provide new developers with a solid understanding of GitPandas, its capabilities, and how to effectively use it for git repository analysis.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
---
|
|
2
|
+
description:
|
|
3
|
+
globs: tests/*
|
|
4
|
+
---
|
|
5
|
+
# Pytest Standards
|
|
6
|
+
|
|
7
|
+
## Test Organization
|
|
8
|
+
- All test files should be named with the prefix `test_` (e.g., `test_module.py`)
|
|
9
|
+
- Test classes should be named with the prefix `Test` (e.g., `TestClassName`)
|
|
10
|
+
- Test methods should be named with the prefix `test_` (e.g., `test_function_name`)
|
|
11
|
+
- Tests should be organized in the same directory structure as the source code they test
|
|
12
|
+
|
|
13
|
+
## Test Structure
|
|
14
|
+
- Each test should focus on testing a single functionality
|
|
15
|
+
- Use descriptive test names that explain what is being tested
|
|
16
|
+
- Group related tests in test classes
|
|
17
|
+
- Use appropriate fixtures for test setup and teardown
|
|
18
|
+
- Avoid test interdependence - tests should be able to run in any order
|
|
19
|
+
|
|
20
|
+
## Assertions
|
|
21
|
+
- Use pytest's built-in assertions instead of Python's `assert` statement when possible
|
|
22
|
+
- Use appropriate assertion methods for the type being tested (e.g., `assert_almost_equal` for floats)
|
|
23
|
+
- Include descriptive error messages in assertions to aid debugging
|
|
24
|
+
|
|
25
|
+
## Fixtures
|
|
26
|
+
- Use fixtures for common setup and teardown operations
|
|
27
|
+
- Define fixtures at the appropriate scope (function, class, module, or session)
|
|
28
|
+
- Use parameterized fixtures for testing multiple inputs
|
|
29
|
+
- Use conftest.py for sharing fixtures across multiple test files
|
|
30
|
+
|
|
31
|
+
## Coverage
|
|
32
|
+
- Aim for at least 80% code coverage
|
|
33
|
+
- Write tests for both success and failure cases
|
|
34
|
+
- Test edge cases and boundary conditions
|
|
35
|
+
- Use `pytest-cov` to generate coverage reports
|
|
36
|
+
|
|
37
|
+
## Best Practices
|
|
38
|
+
- Keep tests fast and independent
|
|
39
|
+
- Avoid mocking unless necessary
|
|
40
|
+
- Use markers to categorize tests (e.g., `@pytest.mark.slow`)
|
|
41
|
+
- Use parametrize for testing multiple inputs
|
|
42
|
+
- Write tests before or alongside code (TDD approach)
|
|
43
|
+
- Run the full test suite before committing changes
|
|
44
|
+
|
|
45
|
+
## Commands
|
|
46
|
+
- Run tests with `pytest`
|
|
47
|
+
- Generate coverage reports with `pytest --cov=gitpandas`
|
|
48
|
+
- Run specific tests with `pytest path/to/test_file.py::TestClass::test_method`
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
---
|
|
2
|
+
description:
|
|
3
|
+
globs: *.py
|
|
4
|
+
---
|
|
5
|
+
# Python Coding Standards
|
|
6
|
+
|
|
7
|
+
## Important Notes
|
|
8
|
+
- Do not ever ever add test-case specific handling into the library code. Do not add handling for "special cases", "test cases" or any other logic branches that attempt to skip the normal buisness logic to get a test to pass.
|
|
9
|
+
|
|
10
|
+
## Code Style
|
|
11
|
+
- Follow PEP 8 style guide for Python code
|
|
12
|
+
- Use 4 spaces for indentation (no tabs)
|
|
13
|
+
- Maximum line length of 88 characters (Black default)
|
|
14
|
+
- Use snake_case for variables, functions, and methods
|
|
15
|
+
- Use CamelCase for classes
|
|
16
|
+
- Use UPPER_CASE for constants
|
|
17
|
+
- Add a blank line at the end of each file
|
|
18
|
+
|
|
19
|
+
## Imports
|
|
20
|
+
- Group imports in the following order:
|
|
21
|
+
1. Standard library imports
|
|
22
|
+
2. Related third-party imports
|
|
23
|
+
3. Local application/library specific imports
|
|
24
|
+
- Use absolute imports when possible
|
|
25
|
+
- Avoid wildcard imports (`from module import *`)
|
|
26
|
+
- Use import aliases for long module names
|
|
27
|
+
|
|
28
|
+
## Documentation
|
|
29
|
+
- Document all public modules, classes, methods, and functions
|
|
30
|
+
- Use docstrings that follow the Google style guide
|
|
31
|
+
- Include type hints for function parameters and return values
|
|
32
|
+
- Document parameters, return values, and exceptions raised
|
|
33
|
+
|
|
34
|
+
## Error Handling
|
|
35
|
+
- Use specific exception types instead of generic ones
|
|
36
|
+
- Handle exceptions at the appropriate level
|
|
37
|
+
- Use context managers (`with` statements) for resource management
|
|
38
|
+
- Avoid catching exceptions without proper handling
|
|
39
|
+
|
|
40
|
+
## Code Organization
|
|
41
|
+
- Keep functions and methods short and focused
|
|
42
|
+
- Follow the Single Responsibility Principle
|
|
43
|
+
- Use classes to encapsulate related functionality
|
|
44
|
+
- Separate concerns into different modules
|
|
45
|
+
|
|
46
|
+
## Testing
|
|
47
|
+
- Write unit tests for all code
|
|
48
|
+
- Use meaningful test names
|
|
49
|
+
- Test both normal and edge cases
|
|
50
|
+
- Mock external dependencies in tests
|
|
51
|
+
|
|
52
|
+
## Performance
|
|
53
|
+
- Prefer list/dict/set comprehensions over loops when appropriate
|
|
54
|
+
- Use generators for large data sets
|
|
55
|
+
- Profile code before optimizing
|
|
56
|
+
- Consider using NumPy/Pandas for numerical operations
|
|
57
|
+
|
|
58
|
+
## Tools
|
|
59
|
+
- Use Black for code formatting
|
|
60
|
+
- Use Ruff for linting and static analysis
|
|
61
|
+
- Use mypy for type checking
|
|
62
|
+
- Use isort for import sorting
|
|
63
|
+
|
|
64
|
+
## Version Control
|
|
65
|
+
- Write meaningful commit messages
|
|
66
|
+
- Keep commits focused on a single change
|
|
67
|
+
- Use feature branches for development
|
|
68
|
+
- Review code before merging
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
---
|
|
2
|
+
description:
|
|
3
|
+
globs: docs/*
|
|
4
|
+
---
|
|
5
|
+
# Sphinx Documentation Standards
|
|
6
|
+
|
|
7
|
+
## Project Setup
|
|
8
|
+
- Use `sphinx-quickstart` to initialize the documentation structure
|
|
9
|
+
- Configure `conf.py` with appropriate project information
|
|
10
|
+
- Use the ReadTheDocs theme for consistent styling
|
|
11
|
+
- Enable necessary extensions (e.g., `autodoc`, `napoleon`, `viewcode`)
|
|
12
|
+
|
|
13
|
+
## Directory Structure
|
|
14
|
+
- Keep documentation source files in the `docs/` directory
|
|
15
|
+
- Organize documentation into logical sections (e.g., user guide, API reference)
|
|
16
|
+
- Use a clear and consistent file naming convention
|
|
17
|
+
- Include an `index.rst` file as the documentation entry point
|
|
18
|
+
|
|
19
|
+
## Documentation Style
|
|
20
|
+
- Write in clear, concise language
|
|
21
|
+
- Use present tense and active voice
|
|
22
|
+
- Be consistent with terminology
|
|
23
|
+
- Include examples where appropriate
|
|
24
|
+
- Target the appropriate audience (users, developers, etc.)
|
|
25
|
+
|
|
26
|
+
## reStructuredText Formatting
|
|
27
|
+
- Use proper heading hierarchy (=, -, ~, ^, ")
|
|
28
|
+
- Use bullet lists for unordered items and numbered lists for sequences
|
|
29
|
+
- Use code blocks with appropriate language for syntax highlighting
|
|
30
|
+
- Use cross-references to link between documentation sections
|
|
31
|
+
- Include images and diagrams where they add value
|
|
32
|
+
|
|
33
|
+
## API Documentation
|
|
34
|
+
- Use autodoc to generate API documentation from docstrings
|
|
35
|
+
- Document all public modules, classes, methods, and functions
|
|
36
|
+
- Follow Google or NumPy docstring style consistently
|
|
37
|
+
- Include type information for parameters and return values
|
|
38
|
+
- Document exceptions that may be raised
|
|
39
|
+
|
|
40
|
+
## Examples and Tutorials
|
|
41
|
+
- Include practical examples for common use cases
|
|
42
|
+
- Provide step-by-step tutorials for complex operations
|
|
43
|
+
- Ensure all examples are tested and working
|
|
44
|
+
- Use `literalinclude` to include code examples from actual source files
|
|
45
|
+
|
|
46
|
+
## Building and Testing
|
|
47
|
+
- Build documentation locally before committing changes
|
|
48
|
+
- Check for and fix all warnings during the build process
|
|
49
|
+
- Verify that cross-references work correctly
|
|
50
|
+
- Test documentation on different screen sizes
|
|
51
|
+
|
|
52
|
+
## Deployment
|
|
53
|
+
- Configure automatic documentation builds on ReadTheDocs or GitHub Pages
|
|
54
|
+
- Include a link to the documentation in the project README
|
|
55
|
+
- Version documentation to match software releases
|
|
56
|
+
- Provide a changelog or release notes section
|
|
57
|
+
|
|
58
|
+
## Maintenance
|
|
59
|
+
- Keep documentation up-to-date with code changes
|
|
60
|
+
- Review and update documentation during each release cycle
|
|
61
|
+
- Address user feedback and questions in the documentation
|
|
62
|
+
- Remove outdated or deprecated information
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: how to use the makefile to run tests
|
|
3
|
+
globs:
|
|
4
|
+
---
|
|
5
|
+
# Gitpandas Testing Standards
|
|
6
|
+
|
|
7
|
+
## Running Tests
|
|
8
|
+
|
|
9
|
+
### Using Make Commands
|
|
10
|
+
- Always use `make test` to run the test suite
|
|
11
|
+
- Use `make test-cov` to run tests with coverage reports
|
|
12
|
+
- Use `make test-all` to run tests on all supported Python versions using tox
|
|
13
|
+
|
|
14
|
+
### Test Commands
|
|
15
|
+
```bash
|
|
16
|
+
# Run the standard test suite
|
|
17
|
+
make test
|
|
18
|
+
|
|
19
|
+
# Run tests with coverage
|
|
20
|
+
make test-cov
|
|
21
|
+
|
|
22
|
+
# Run tests on all supported Python versions
|
|
23
|
+
make test-all
|
|
24
|
+
|
|
25
|
+
# Run a specific test file
|
|
26
|
+
make test PYTEST_ARGS="tests/test_unified_interface.py"
|
|
27
|
+
|
|
28
|
+
# Run a specific test class
|
|
29
|
+
make test PYTEST_ARGS="tests/test_unified_interface.py::TestUnifiedInterface"
|
|
30
|
+
|
|
31
|
+
# Run a specific test method
|
|
32
|
+
make test PYTEST_ARGS="tests/test_unified_interface.py::TestUnifiedInterface::test_base_methods_elo"
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Test Environment
|
|
36
|
+
- Tests are run using `uv run pytest` through the Makefile
|
|
37
|
+
- The test environment is automatically set up with the correct dependencies
|
|
38
|
+
- Always run tests in a clean environment to avoid dependency conflicts
|
|
39
|
+
|
|
40
|
+
### Continuous Integration
|
|
41
|
+
- All tests must pass in CI before merging
|
|
42
|
+
- Coverage should not decrease with new code
|
|
43
|
+
- New features should include corresponding tests
|
|
44
|
+
|
|
45
|
+
### Benchmarks
|
|
46
|
+
- Use `make benchmark` to run performance benchmarks
|
|
47
|
+
- Benchmark results are stored in the `benchmark_results` directory
|
|
48
|
+
- Performance regressions should be addressed before merging
|
|
49
|
+
|
|
50
|
+
### Linting and Formatting
|
|
51
|
+
- Use `make lint` to check code quality
|
|
52
|
+
- Use `make lint-fix` to automatically fix linting issues
|
|
53
|
+
- Use `make format` to format code according to project standards
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
name: "Master Docs Publication"
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches: [ master ]
|
|
5
|
+
|
|
6
|
+
jobs:
|
|
7
|
+
docs:
|
|
8
|
+
runs-on: ubuntu-latest
|
|
9
|
+
steps:
|
|
10
|
+
- name: Clone
|
|
11
|
+
uses: actions/checkout@v1
|
|
12
|
+
|
|
13
|
+
- name: Set up Python
|
|
14
|
+
uses: actions/setup-python@v4
|
|
15
|
+
with:
|
|
16
|
+
python-version: '3.10'
|
|
17
|
+
|
|
18
|
+
- name: Install uv
|
|
19
|
+
run: |
|
|
20
|
+
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
21
|
+
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
|
|
22
|
+
|
|
23
|
+
- name: Install Dependencies
|
|
24
|
+
run: |
|
|
25
|
+
uv pip install --system -e ".[dev]"
|
|
26
|
+
|
|
27
|
+
- name: Build Docs
|
|
28
|
+
uses: ammaraskar/sphinx-action@master
|
|
29
|
+
with:
|
|
30
|
+
docs-folder: "./docs/"
|
|
31
|
+
|
|
32
|
+
- name: Create CNAME file
|
|
33
|
+
run: |
|
|
34
|
+
echo "gitpandas.mcginniscommawill.com" > ./docs/build/html/CNAME
|
|
35
|
+
|
|
36
|
+
- name: Deploy Docs
|
|
37
|
+
uses: peaceiris/actions-gh-pages@v3
|
|
38
|
+
with:
|
|
39
|
+
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
40
|
+
publish_dir: "./docs/build/html/"
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
name: "PyPI Packaging"
|
|
2
|
+
on:
|
|
3
|
+
release:
|
|
4
|
+
types: created
|
|
5
|
+
|
|
6
|
+
jobs:
|
|
7
|
+
build_and_publish:
|
|
8
|
+
runs-on: ubuntu-latest
|
|
9
|
+
permissions:
|
|
10
|
+
# IMPORTANT: this permission is mandatory for Trusted Publishing
|
|
11
|
+
id-token: write
|
|
12
|
+
steps:
|
|
13
|
+
- name: Clone
|
|
14
|
+
uses: actions/checkout@v3
|
|
15
|
+
|
|
16
|
+
- name: Set up Python
|
|
17
|
+
uses: actions/setup-python@v4
|
|
18
|
+
with:
|
|
19
|
+
python-version: '3.11'
|
|
20
|
+
|
|
21
|
+
- name: Install uv
|
|
22
|
+
run: |
|
|
23
|
+
python -m pip install --upgrade pip
|
|
24
|
+
pip install uv
|
|
25
|
+
|
|
26
|
+
- name: Setup virtual environment
|
|
27
|
+
run: |
|
|
28
|
+
uv venv
|
|
29
|
+
echo "VIRTUAL_ENV=$(pwd)/.venv" >> $GITHUB_ENV
|
|
30
|
+
echo "$(pwd)/.venv/bin" >> $GITHUB_PATH
|
|
31
|
+
|
|
32
|
+
- name: Install dependencies
|
|
33
|
+
run: |
|
|
34
|
+
uv pip install -e ".[dev]"
|
|
35
|
+
uv pip install build
|
|
36
|
+
|
|
37
|
+
- name: Build source distribution
|
|
38
|
+
run: |
|
|
39
|
+
# Clean the build directories first
|
|
40
|
+
rm -rf build/
|
|
41
|
+
rm -rf dist/
|
|
42
|
+
rm -rf .eggs/
|
|
43
|
+
|
|
44
|
+
# Find and remove egg-info directories, excluding the virtual environment
|
|
45
|
+
find . -path ./.venv -prune -o -name '*.egg-info' -type d -exec rm -rf {} \; 2>/dev/null || true
|
|
46
|
+
find . -path ./.venv -prune -o -name '*.egg' -type f -exec rm -f {} \; 2>/dev/null || true
|
|
47
|
+
find . -path ./.venv -prune -o -name '__pycache__' -type d -exec rm -rf {} \; 2>/dev/null || true
|
|
48
|
+
|
|
49
|
+
# Build only the source distribution
|
|
50
|
+
python -m build --sdist
|
|
51
|
+
|
|
52
|
+
- name: Publish package to PyPI
|
|
53
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
54
|
+
with:
|
|
55
|
+
packages-dir: dist/
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
name: "Pull Request Docs Check"
|
|
2
|
+
on:
|
|
3
|
+
- pull_request
|
|
4
|
+
|
|
5
|
+
jobs:
|
|
6
|
+
docs:
|
|
7
|
+
runs-on: ubuntu-latest
|
|
8
|
+
steps:
|
|
9
|
+
- name: Checkout
|
|
10
|
+
uses: actions/checkout@v1
|
|
11
|
+
|
|
12
|
+
- name: Set up Python
|
|
13
|
+
uses: actions/setup-python@v4
|
|
14
|
+
with:
|
|
15
|
+
python-version: '3.10'
|
|
16
|
+
|
|
17
|
+
- name: Install uv
|
|
18
|
+
run: |
|
|
19
|
+
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
20
|
+
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
|
|
21
|
+
|
|
22
|
+
- name: Install Dependencies
|
|
23
|
+
run: |
|
|
24
|
+
uv pip install --system -e ".[dev]"
|
|
25
|
+
|
|
26
|
+
- name: Build Docs
|
|
27
|
+
uses: ammaraskar/sphinx-action@master
|
|
28
|
+
with:
|
|
29
|
+
docs-folder: "docs/"
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
|
|
2
|
+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
|
|
3
|
+
|
|
4
|
+
name: "Test Suite and Linting"
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
push:
|
|
8
|
+
branches: [ master ]
|
|
9
|
+
pull_request:
|
|
10
|
+
branches: [ master ]
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
test:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
|
|
16
|
+
steps:
|
|
17
|
+
- name: Checkout code
|
|
18
|
+
uses: actions/checkout@v3
|
|
19
|
+
|
|
20
|
+
- name: Set up Python
|
|
21
|
+
uses: actions/setup-python@v4
|
|
22
|
+
with:
|
|
23
|
+
python-version: '3.10'
|
|
24
|
+
|
|
25
|
+
- name: Install uv
|
|
26
|
+
run: |
|
|
27
|
+
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
28
|
+
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
|
|
29
|
+
|
|
30
|
+
- name: Install dependencies
|
|
31
|
+
run: |
|
|
32
|
+
uv pip install --system -e ".[dev,datasets]"
|
|
33
|
+
|
|
34
|
+
- name: Configure Git
|
|
35
|
+
run: |
|
|
36
|
+
git config --global user.email "github-actions@github.com"
|
|
37
|
+
git config --global user.name "GitHub Actions"
|
|
38
|
+
|
|
39
|
+
- name: Run tests
|
|
40
|
+
run: |
|
|
41
|
+
make test
|
|
42
|
+
|
|
43
|
+
- name: Run linting
|
|
44
|
+
run: |
|
|
45
|
+
make lint
|