Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 27 additions & 29 deletions .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,54 +6,52 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11", "3.12", "3.13"]
python-version: ["3.11", "3.12", "3.13", "3.14"]
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: Set up Python
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}

- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true

- name: Install dependencies
run: |
python3 -m pip install ".[tests]"
run: uv sync --extra tests

- name: Run tests
run: python3 -m pytest
run: uv run pytest

precommit_hooks:
runs-on: ubuntu-latest
strategy:
matrix:
cmd:
- "end-of-file-fixer"
- "trailing-whitespace"
- "mixed-line-ending"
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: Set up Python 3.12
uses: actions/setup-python@v5
- uses: j178/prek-action@v1
with:
python-version: 3.12
extra_args: '--all-files --skip "ruff-format" --skip "ruff-check"'

- uses: pre-commit/[email protected]
with:
extra_args: ${{ matrix.cmd }} --all-files
lint:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true

- name: Install dependencies
run: python3 -m pip install ".[dev]"
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: 3.13

- name: Install dependencies
run: uv sync --extra dev

- name: Check style
run: python3 -m ruff check . && python3 -m ruff format --check .
- name: Check style
run: uv run ruff check . && uv run ruff format --check .
27 changes: 17 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0 # pre-commit-hooks version
rev: v6.0.0 # pre-commit-hooks version
hooks:
- id: check-added-large-files
args: ['--maxkb=1500'] # for clinicaltrials.gov API fixture
- id: detect-private-key
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-merge-conflict
- id: detect-aws-credentials
args: [ --allow-missing-credentials ]
- repo: builtin
hooks:
- id: trailing-whitespace
- id: check-added-large-files
args: ['--maxkb=1500']
- id: check-case-conflict
- id: end-of-file-fixer
- id: fix-byte-order-marker
- id: check-json
- id: check-toml
- id: check-yaml
- id: mixed-line-ending
args: [ --fix=lf ]
- id: check-merge-conflict
- id: detect-private-key
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.12.1 # ruff version
rev: v0.14.10 # ruff version
hooks:
- id: ruff-format
- id: ruff
- id: ruff-check
args: [ --fix, --exit-non-zero-on-fix ]
minimum_pre_commit_version: 4.2.0
minimum_prek_version: 0.2.23
145 changes: 55 additions & 90 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@ classifiers = [
"Intended Audience :: Science/Research",
"Intended Audience :: Developers",
"Topic :: Scientific/Engineering :: Bio-Informatics",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
]
license = "MIT"
license-files = ["LICENSE"]
requires-python = ">=3.11"
description = "Fetch regulatory approval data for drug terms"
license = {file = "LICENSE"}
description = "Easily fetch and operate on data from medical & drug regulatory agencies"
dependencies = ["requests"]
dynamic = ["version"]

[project.optional-dependencies]
tests = ["pytest", "pytest-cov", "requests-mock"]
dev = [
"pre-commit>=4.2.0",
"ruff==0.12.1",
"prek>=0.2.23",
"ruff==0.14.10",
]

[project.urls]
Expand Down Expand Up @@ -58,109 +58,74 @@ src = ["src"]


[tool.ruff.lint]
select = [
"F", # https://docs.astral.sh/ruff/rules/#pyflakes-f
"E", "W", # https://docs.astral.sh/ruff/rules/#pycodestyle-e-w
"I", # https://docs.astral.sh/ruff/rules/#isort-i
"N", # https://docs.astral.sh/ruff/rules/#pep8-naming-n
"D", # https://docs.astral.sh/ruff/rules/#pydocstyle-d
"UP", # https://docs.astral.sh/ruff/rules/#pyupgrade-up
"ANN", # https://docs.astral.sh/ruff/rules/#flake8-annotations-ann
"ASYNC", # https://docs.astral.sh/ruff/rules/#flake8-async-async
"S", # https://docs.astral.sh/ruff/rules/#flake8-bandit-s
"B", # https://docs.astral.sh/ruff/rules/#flake8-bugbear-b
"A", # https://docs.astral.sh/ruff/rules/#flake8-builtins-a
"C4", # https://docs.astral.sh/ruff/rules/#flake8-comprehensions-c4
"DTZ", # https://docs.astral.sh/ruff/rules/#flake8-datetimez-dtz
"T10", # https://docs.astral.sh/ruff/rules/#flake8-datetimez-dtz
"EM", # https://docs.astral.sh/ruff/rules/#flake8-errmsg-em
"LOG", # https://docs.astral.sh/ruff/rules/#flake8-logging-log
"G", # https://docs.astral.sh/ruff/rules/#flake8-logging-format-g
"INP", # https://docs.astral.sh/ruff/rules/#flake8-no-pep420-inp
"PIE", # https://docs.astral.sh/ruff/rules/#flake8-pie-pie
"T20", # https://docs.astral.sh/ruff/rules/#flake8-print-t20
"PT", # https://docs.astral.sh/ruff/rules/#flake8-pytest-style-pt
"Q", # https://docs.astral.sh/ruff/rules/#flake8-quotes-q
"RSE", # https://docs.astral.sh/ruff/rules/#flake8-raise-rse
"RET", # https://docs.astral.sh/ruff/rules/#flake8-return-ret
"SLF", # https://docs.astral.sh/ruff/rules/#flake8-self-slf
"SLOT", # https://docs.astral.sh/ruff/rules/#flake8-slots-slot
"SIM", # https://docs.astral.sh/ruff/rules/#flake8-simplify-sim
"ARG", # https://docs.astral.sh/ruff/rules/#flake8-unused-arguments-arg
"PTH", # https://docs.astral.sh/ruff/rules/#flake8-use-pathlib-pth
"PGH", # https://docs.astral.sh/ruff/rules/#pygrep-hooks-pgh
"PLC", # https://docs.astral.sh/ruff/rules/#convention-c
"PLE", # https://docs.astral.sh/ruff/rules/#error-e_1
"TRY", # https://docs.astral.sh/ruff/rules/#tryceratops-try
"PERF", # https://docs.astral.sh/ruff/rules/#perflint-perf
"FURB", # https://docs.astral.sh/ruff/rules/#refurb-furb
"RUF", # https://docs.astral.sh/ruff/rules/#ruff-specific-rules-ruf
]
fixable = [
"I",
"F401",
"D",
"UP",
"ANN",
"B",
"C4",
"LOG",
"G",
"PIE",
"PT",
"RSE",
"SIM",
"PLC",
"PLE",
"TRY",
"PERF",
"FURB",
"RUF"
]
# ANN003 - missing-type-kwargs
# D203 - one-blank-line-before-class
# D205 - blank-line-after-summary
# D206 - indent-with-spaces*
# D213 - multi-line-summary-second-line
# D300 - triple-single-quotes*
# D400 - ends-in-period
# D415 - ends-in-punctuation
# E111 - indentation-with-invalid-multiple*
# E114 - indentation-with-invalid-multiple-comment*
# E117 - over-indented*
# E501 - line-too-long*
# W191 - tab-indentation*
# S321 - suspicious-ftp-lib-usage
# PLC0206 - dict-index-missing-items
# *ignored for compatibility with formatter
select = ["ALL"]
ignore = [
"ANN003",
"D203", "D205", "D206", "D213", "D300", "D400", "D415",
"E111", "E114", "E117", "E501",
# unused
"AIR",
"ERA",
"YTT",
"BLE",
"FBT",
"CPY",
"DJ",
"EXE",
"FIX",
"FA",
"PYI",
"TD",
"C90",
"NPY",
"PD",
# ignore for compatibility with formatter
"D206",
"D300",
"W191",
"E111",
"E114",
"E117",
"E501",
"W191",
"S321",
"COM812",
"COM819",
"Q000",
"Q001",
"Q002",
"Q003",
# don't require types on *args, **kwargs
"ANN002",
"ANN003",
# subjective pylint thresholds
"PLR0904",
"PLR091",
"PLR1702",
"PLC0206",
# misc unnecessary stuff
"S321",
"D203",
"D205",
"D213",
"D400",
"D415",
]

[tool.ruff.lint.per-file-ignores]
# ANN001 - missing-type-function-argument
# ANN2 - missing-return-type
# D100 - undocumented-public-module
# D102 - undocumented-public-class
# S101 - assert
# B011 - assert-false
# INP001 - implicit-namespace-package
# D103 - missing-docstring-public-function
# PLR2004 - magic-value-comparison
"tests/*" = [
"ANN001",
"ANN2",
"D100",
"D102",
"D103",
"D",
"S101",
"B011",
"INP001"
"INP001",
"PLR2004",
]

[tool.ruff.lint.flake8-annotations]
mypy-init-return = true

Expand Down
3 changes: 2 additions & 1 deletion src/regbot/fetch/drugsfda.py
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,7 @@ def make_drugsatfda_request(url: str, limit: int = 500) -> list[Result] | None:
results = []
remaining = True
skip = 0
skip_ceiling = 25000 # arbitrary, unrealistic ceiling to prevent insane skip values
while remaining:
full_url = f"{url}&limit={limit}&skip={skip}"
_logger.debug("Issuing GET request to %s", full_url)
Expand All @@ -650,7 +651,7 @@ def make_drugsatfda_request(url: str, limit: int = 500) -> list[Result] | None:
data = r.json()
results += data["results"]
skip = data["meta"]["results"]["skip"] + len(data["results"])
remaining = (data["meta"]["results"]["total"] > skip) or (skip >= 25000)
remaining = (data["meta"]["results"]["total"] > skip) or (skip >= skip_ceiling)
return [_get_result(r) for r in results]


Expand Down
Loading