Skip to content

Commit 4e3f78d

Browse files
authored
Merge pull request #36 from HzaCode/pyopensci-review
pyOpenSci review improvements
2 parents ac9641d + 3493b43 commit 4e3f78d

22 files changed

Lines changed: 1332 additions & 601 deletions

.github/workflows/tests.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- name: Install dependencies
2626
run: |
2727
python -m pip install --upgrade pip
28-
pip install ".[dev,plot]" pytest-cov coverage-badge
28+
pip install ".[dev,plot]" pytest-cov coverage-badge mypy types-requests
2929
3030
- name: Verify plotting libraries
3131
run: |
@@ -37,6 +37,14 @@ jobs:
3737
print("matplotlib", matplotlib.__version__)
3838
PY
3939
40+
- name: Run linting with ruff
41+
run: |
42+
ruff check src/ tests/
43+
ruff format --check src/ tests/
44+
45+
- name: Run type checking with mypy
46+
run: mypy src/ChemInformant --ignore-missing-imports --allow-untyped-defs --allow-incomplete-defs --no-strict-optional
47+
4048
- name: Run tests with coverage
4149
env:
4250
PYTHONPATH: ${{ github.workspace }}/src

README.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<img src="https://img.shields.io/pypi/v/ChemInformant.svg" alt="PyPI version">
1919
</a>
2020
<a href="https://pypi.org/project/ChemInformant/">
21-
<img src="https://img.shields.io/badge/python-%3E%3D3.8-blue.svg" alt="Python Version">
21+
<img src="https://img.shields.io/badge/python-%3E%3D3.9-blue.svg" alt="Python Version">
2222
</a>
2323
<a href="https://github.com/HzaCode/ChemInformant/blob/main/LICENSE.md">
2424
<img src="https://img.shields.io/pypi/l/ChemInformant.svg" alt="License">
@@ -27,7 +27,10 @@
2727

2828
<p>
2929
<a href="https://github.com/HzaCode/ChemInformant/actions/workflows/tests.yml">
30-
<img src="https://img.shields.io/github/actions/workflow/status/HzaCode/ChemInformant/tests.yml?label=Build" alt="Build Status">
30+
<img src="https://img.shields.io/github/actions/workflow/status/HzaCode/ChemInformant/tests.yml?label=Tests" alt="Tests Status">
31+
</a>
32+
<a href="https://github.com/HzaCode/ChemInformant/actions/workflows/docs-deploy.yml">
33+
<img src="https://img.shields.io/github/actions/workflow/status/HzaCode/ChemInformant/docs-deploy.yml?label=Docs" alt="Docs Build Status">
3134
</a>
3235
<a href="https://cdn.jsdelivr.net/gh/HzaCode/ChemInformant@gh-pages/coverage.svg">
3336
<img src="https://cdn.jsdelivr.net/gh/HzaCode/ChemInformant@gh-pages/coverage.svg" alt="coverage">
@@ -170,7 +173,15 @@ For a deep dive, please see our detailed guides:
170173

171174
* **➡️ Online Documentation:** The **[official documentation site](https://hezhiang.com/ChemInformant)** contains complete API references, guides, and usage examples. **This is the most comprehensive resource.**
172175
* **➡️ Interactive User Manual:** Our [**Jupyter Notebook Tutorial**](examples/ChemInformant_User_Manual_v1.0.ipynb) provides a complete, end-to-end walkthrough. This is the best place to start for a hands-on experience.
173-
* **➡️ Performance Benchmarks:** You can review and run our [**Benchmark Script**](./benchmark.py) to see the performance advantages of batching and caching.
176+
* **➡️ Performance Benchmarks:** Run integrated benchmarks with `pytest tests/test_benchmarks.py --benchmark-only` to see the performance advantages of batching and caching.
177+
178+
#### 📖 Additional Resources & Use Cases
179+
180+
* **[Basic Usage Guide](https://hezhiang.com/ChemInformant/basic_usage.html)** - Quick start examples for common tasks
181+
* **[Advanced Usage Guide](https://hezhiang.com/ChemInformant/advanced_usage.html)** - Complex workflows and batch processing
182+
* **[Caching Guide](https://hezhiang.com/ChemInformant/caching_guide.html)** - Optimize performance with intelligent caching
183+
* **[CLI Tools Documentation](https://hezhiang.com/ChemInformant/cli.html)** - Complete reference for `chemfetch` and `chemdraw`
184+
* **[API Reference](https://hezhiang.com/ChemInformant/api/)** - Full function documentation with examples
174185

175186
---
176187

benchmark.py

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

docs/requirements.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
sphinx
22
sphinx-rtd-theme
3+
sphinx-copybutton
34

4-
# myst-parser
5-
# sphinx-copybutton
5+
# Required for consistent syntax highlighting
6+
pygments>=2.17.0

docs/source/conf.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,30 @@
2020
"sphinx.ext.viewcode",
2121
"sphinx.ext.intersphinx",
2222
"sphinx.ext.todo",
23+
"sphinx_copybutton",
2324
]
2425

2526
templates_path = ["_templates"]
2627
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
2728
source_suffix = ".rst"
28-
pygments_style = "sphinx"
29+
pygments_style = "default"
30+
31+
# -- Syntax highlighting configuration ----------------------------------------
32+
# Ensure consistent syntax highlighting across all code blocks
33+
highlight_language = "python"
34+
highlight_options = {
35+
'default': {'stripall': False},
36+
'python': {'stripall': False},
37+
'bash': {'stripall': False},
38+
'text': {'stripall': False},
39+
}
40+
41+
# -- Copy button configuration -----------------------------------------------
42+
# Configure sphinx-copybutton to skip prompts and output
43+
copybutton_prompt_text = r">>> |\.\.\. |\$ |In \[\d*\]: | {2,5}\.\.\.: | {5,8}: "
44+
copybutton_prompt_is_regexp = True
45+
copybutton_only_copy_prompt_lines = False
46+
copybutton_remove_prompts = True
2947

3048
# -- HTML output --------------------------------------------------------------
3149
html_theme = "sphinx_rtd_theme"

docs/source/installation.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ If you wish to get the latest, unreleased development version, or if you plan to
5353
* **To set up a complete environment for development contribution:**
5454
This command will install all dependencies, including the core library, plotting functionality, and development tools for testing and code checking (like `pytest`, `black`). This is the recommended command for contributors.
5555

56-
.. code-tally-block:: bash
56+
.. code-block:: bash
5757
5858
pip install -e .[all]
5959

pyproject.toml

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ authors = [
1414
]
1515
description = "A robust and high-throughput Python client for the PubChem API, designed for automated data retrieval and analysis"
1616
readme = { file = "README.md", content-type = "text/markdown" }
17-
requires-python = ">=3.8"
17+
requires-python = ">=3.9"
1818
license = "MIT"
1919
classifiers = [
2020
"Programming Language :: Python :: 3",
21-
"Programming Language :: Python :: 3.8",
2221
"Programming Language :: Python :: 3.9",
2322
"Programming Language :: Python :: 3.10",
2423
"Programming Language :: Python :: 3.11",
2524
"Programming Language :: Python :: 3.12",
25+
"Programming Language :: Python :: 3.13",
2626
"Operating System :: OS Independent",
2727
"Topic :: Scientific/Engineering :: Chemistry",
2828
]
@@ -71,7 +71,9 @@ dev = [
7171
"pytest>=7.0",
7272
"pytest-mock>=3.5",
7373
"pytest-cov>=2.12",
74-
"ruff"
74+
"pytest-benchmark>=4.0",
75+
"ruff",
76+
"mypy"
7577
]
7678

7779
[tool.setuptools.packages.find]
@@ -86,7 +88,7 @@ source = ["ChemInformant"]
8688
[tool.ruff]
8789
# Set line length to match black formatter
8890
line-length = 88
89-
target-version = "py38"
91+
target-version = "py39"
9092

9193
[tool.ruff.lint]
9294
# Enabled rule sets, replacing multiple tools:
@@ -103,6 +105,9 @@ select = ["E", "W", "F", "I", "N", "UP", "B", "C4", "SIM"]
103105
# Ignored rules
104106
ignore = [
105107
"E501", # Line length handled by formatter
108+
"N999", # Invalid module name (ChemInformant is a valid name)
109+
"N813", # Camelcase imported as lowercase (common for packages)
110+
"SIM117", # Multiple context managers (sometimes clearer as nested)
106111
]
107112

108113
[tool.ruff.lint.isort]
@@ -115,3 +120,32 @@ quote-style = "double"
115120
indent-style = "space"
116121
skip-magic-trailing-comma = false
117122
line-ending = "auto"
123+
124+
# ---------------------------
125+
# MyPy configuration
126+
# ---------------------------
127+
[tool.mypy]
128+
python_version = "3.9"
129+
warn_return_any = true
130+
warn_unused_configs = true
131+
disallow_untyped_defs = true
132+
disallow_incomplete_defs = true
133+
check_untyped_defs = true
134+
disallow_untyped_decorators = true
135+
no_implicit_optional = true
136+
warn_redundant_casts = true
137+
warn_unused_ignores = true
138+
warn_no_return = true
139+
warn_unreachable = true
140+
strict_equality = true
141+
142+
[[tool.mypy.overrides]]
143+
module = [
144+
"requests_cache.*",
145+
"pubchempy.*",
146+
"matplotlib.*",
147+
"seaborn.*",
148+
"sklearn.*",
149+
"PIL.*"
150+
]
151+
ignore_missing_imports = true

pytest-benchmark.ini

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[tool:pytest-benchmark]
2+
# Benchmark configuration for ChemInformant
3+
min_rounds = 3
4+
max_time = 30.0
5+
min_time = 0.1
6+
timer = time.perf_counter
7+
disable_gc = true
8+
warmup = true
9+
warmup_iterations = 2
10+
11+
# Output options
12+
sort = mean
13+
columns = min,max,mean,stddev,rounds,iterations
14+
histogram = true
15+
16+
# Save results
17+
save = .benchmarks
18+
save-data = true
19+
autosave = true
20+
21+
# Compare with previous runs
22+
compare = 0001
23+
compare-fail = mean:10%

0 commit comments

Comments
 (0)