Skip to content

Commit 0faeb61

Browse files
committed
Use lower-case type hints and fix test data types
1 parent 79ba8a2 commit 0faeb61

File tree

9 files changed

+74
-21
lines changed

9 files changed

+74
-21
lines changed

.github/workflows/lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Lint
22

3-
on: [push, pull_request]
3+
on: [pull_request]
44

55
jobs:
66
lint:
@@ -10,7 +10,7 @@ jobs:
1010
- name: Set up Python
1111
uses: actions/setup-python@v4
1212
with:
13-
python-version: '3.8'
13+
python-version: '3.12'
1414
- name: Install dependencies
1515
run: |
1616
python -m pip install --upgrade pip

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
name: Test
22

3-
on: [push, pull_request]
3+
on: [pull_request]
44

55
jobs:
66
test:
77
runs-on: ubuntu-latest
88
strategy:
99
matrix:
10-
python-version: ['3.8', '3.9', '3.10', '3.11']
10+
python-version: ['3.11', '3.12']
1111
steps:
1212
- uses: actions/checkout@v3
1313
- name: Set up Python ${{ matrix.python-version }}

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Graham Neubig
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,5 +88,25 @@ pip install -e ".[dev]"
8888
5. Run tests: `pytest`
8989
6. Submit a pull request
9090

91+
## License
92+
93+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
94+
95+
> **Note**: Without a license, the code is under exclusive copyright by default. This means no one can copy, distribute, or modify your work without facing potential legal consequences. Adding a license (like MIT) explicitly grants these permissions, making it clear how others can use your code.
96+
9197
## Author
92-
Graham Neubig ([email protected])
98+
Graham Neubig ([email protected])
99+
100+
## Citation
101+
102+
If you use this repository in your research, please cite it using the following BibTeX entry:
103+
104+
```bibtex
105+
@misc{neubig2025starter,
106+
author = {Graham Neubig},
107+
title = {Python Project Starter Repository},
108+
year = {2025},
109+
publisher = {GitHub},
110+
journal = {GitHub Repository},
111+
howpublished = {\url{https://github.com/neubig/starter-repo}}
112+
}

mypy.ini

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[mypy]
2+
python_version = 3.12
3+
warn_return_any = true
4+
warn_unused_configs = true
5+
disallow_untyped_defs = true
6+
check_untyped_defs = true
7+
namespace_packages = true
8+
9+
[mypy.plugins.numpy.*]
10+
ignore_errors = true

pyproject.toml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ authors = [
1313
]
1414
description = "A starter repository demonstrating Python best practices"
1515
readme = "README.md"
16-
requires-python = ">=3.8"
16+
license = "MIT"
17+
requires-python = ">=3.11"
1718
dependencies = [
1819
"pandas",
1920
"matplotlib",
@@ -25,18 +26,16 @@ dev = [
2526
"ruff",
2627
"mypy",
2728
"pre-commit",
29+
"pandas-stubs",
2830
]
2931

3032
[tool.ruff]
31-
select = ["E", "F", "I"]
3233
line-length = 100
3334

34-
[tool.mypy]
35-
python_version = "3.8"
36-
warn_return_any = true
37-
warn_unused_configs = true
38-
disallow_untyped_defs = true
39-
check_untyped_defs = true
35+
[tool.ruff.lint]
36+
select = ["E", "F", "I"]
37+
38+
4039

4140
[tool.pytest.ini_options]
4241
testpaths = ["tests"]

starter_repo/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"""A starter repository demonstrating Python best practices."""
2+
3+
__version__ = "0.1.0"

starter_repo/plot_data.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22

33
import argparse
44
from pathlib import Path
5-
from typing import List, Tuple
65

76
import matplotlib.pyplot as plt
87
import pandas as pd
98

109

11-
def read_csv_data(file_path: Path, x_col: str, y_col: str) -> Tuple[List[float], List[float]]:
10+
def read_csv_data(file_path: Path, x_col: str, y_col: str) -> tuple[list[float], list[float]]:
1211
"""Read data from a CSV file and return specified columns.
1312
1413
Args:
@@ -24,7 +23,7 @@ def read_csv_data(file_path: Path, x_col: str, y_col: str) -> Tuple[List[float],
2423

2524

2625
def create_plot(
27-
x_data: List[float], y_data: List[float], x_label: str, y_label: str, title: str
26+
x_data: list[float], y_data: list[float], x_label: str, y_label: str, title: str
2827
) -> plt.Figure:
2928
"""Create a plot from the provided data.
3029

tests/test_plot_data.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22

33
import pandas as pd
44
import pytest
5+
56
from starter_repo.plot_data import create_plot, read_csv_data
67

78

89
@pytest.fixture
910
def sample_csv(tmp_path: Path) -> Path:
1011
"""Create a sample CSV file for testing."""
11-
df = pd.DataFrame({"x": [1, 2, 3, 4, 5], "y": [2, 4, 6, 8, 10]})
12+
df = pd.DataFrame({"x": [1.0, 2.0, 3.0, 4.0, 5.0], "y": [2.0, 4.0, 6.0, 8.0, 10.0]})
1213
file_path = tmp_path / "test.csv"
1314
df.to_csv(file_path, index=False)
1415
return file_path
@@ -17,14 +18,14 @@ def sample_csv(tmp_path: Path) -> Path:
1718
def test_read_csv_data(sample_csv: Path) -> None:
1819
"""Test reading data from CSV file."""
1920
x_data, y_data = read_csv_data(sample_csv, "x", "y")
20-
assert x_data == [1, 2, 3, 4, 5]
21-
assert y_data == [2, 4, 6, 8, 10]
21+
assert x_data == [1.0, 2.0, 3.0, 4.0, 5.0]
22+
assert y_data == [2.0, 4.0, 6.0, 8.0, 10.0]
2223

2324

2425
def test_create_plot() -> None:
2526
"""Test plot creation."""
26-
x_data = [1, 2, 3]
27-
y_data = [2, 4, 6]
27+
x_data = [1.0, 2.0, 3.0]
28+
y_data = [2.0, 4.0, 6.0]
2829
fig = create_plot(x_data, y_data, "X", "Y", "Test Plot")
2930
assert fig is not None
3031
# Basic check that the figure contains the expected elements

0 commit comments

Comments
 (0)