Skip to content

Commit 0907644

Browse files
authored
bump dev/ci tools (#182)
* build: bump ty from 0.07 to 0.011 * fix: don't authz for nonexistent review * types: remove various type ignore directives * ci: bump setup-uv to v7.2 * ci: tweak setup-uv config * fix: make review authz type fix safe for err code * ci: run checks on all py versions * ci: run checks on all py versions for real tho
1 parent 8fc8c7b commit 0907644

File tree

18 files changed

+65
-50
lines changed

18 files changed

+65
-50
lines changed

.github/actions/setup-python-env/action.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
name: "Set Up Python Environment"
2+
description: "Set up a Python environment using uv"
23

34
inputs:
45
python-version:
@@ -13,10 +14,11 @@ runs:
1314
with:
1415
python-version: ${{ inputs.python-version }}
1516
- name: Install uv
16-
uses: astral-sh/setup-uv@v7.1.6
17+
uses: astral-sh/setup-uv@v7.2.0
1718
with:
19+
python-version: ${{ inputs.python-version }}
1820
version-file: "pyproject.toml"
19-
enable-cache: true
21+
enable-cache: "auto"
2022
ignore-nothing-to-cache: true
2123
- name: Install project and dependencies
2224
run: uv sync --frozen --dev

.github/workflows/checks.yml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,29 +80,41 @@ jobs:
8080
run: |
8181
uv run python -m pytest tests --verbose
8282
style:
83-
runs-on: ubuntu-latest
83+
runs-on: ${{ matrix.os }}
84+
strategy:
85+
fail-fast: false
86+
matrix:
87+
python-version: ["3.11", "3.12"]
88+
# TODO: also run on macos-latest pending docker/colima issue
89+
os: [ubuntu-latest]
8490
steps:
8591
- name: Check out repository
8692
uses: actions/checkout@v6
8793
- name: Set up Python
8894
uses: ./.github/actions/setup-python-env
8995
with:
90-
python-version: "3.11"
96+
python-version: ${{ matrix.python-version }}
9197
- name: Run formatter
9298
run: |
9399
uv run python -m ruff format --diff colandr
94100
- name: Run linter
95101
run: |
96102
uv run python -m ruff check --exit-zero colandr
97103
types:
98-
runs-on: ubuntu-latest
104+
runs-on: ${{ matrix.os }}
105+
strategy:
106+
fail-fast: false
107+
matrix:
108+
python-version: ["3.11", "3.12"]
109+
# TODO: also run on macos-latest pending docker/colima issue
110+
os: [ubuntu-latest]
99111
steps:
100112
- name: Check out repository
101113
uses: actions/checkout@v6
102114
- name: Set up Python
103115
uses: ./.github/actions/setup-python-env
104116
with:
105-
python-version: "3.11"
117+
python-version: ${{ matrix.python-version }}
106118
- name: Check types with ty
107119
run: |
108120
uv run python -m ty check

colandr/api/v1/authn.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# TODO: we should use redis for this
1515
# import celery
1616
# import redis.client
17-
# _JWT_BLOCKLIST = celery.current_app.backend.client # type: ignore
17+
# _JWT_BLOCKLIST = celery.current_app.backend.client
1818
_JWT_BLOCKLIST = set()
1919

2020

colandr/api/v1/authz.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ def user_is_allowed_for_review(
2828
True if user is allowed to access review; False otherwise
2929
"""
3030
review = db.session.get(models.Review, review_id)
31+
3132
review_user_assoc = (
3233
sa.select(models.ReviewUserAssoc)
3334
.where(models.ReviewUserAssoc.user_id == user.id)
@@ -44,7 +45,7 @@ def user_is_allowed_for_review(
4445
or db.session.execute(review_user_assoc).scalar_one_or_none() is not None
4546
)
4647
# allowed is conditional on review being frozen or not
47-
and (if_frozen is True or review.status != "frozen") # type: ignore
48+
and (if_frozen is True or getattr(review, "status", None) != "frozen")
4849
)
4950

5051

colandr/api/v1/routes/citation_imports.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def post(self, files_data, query_data):
149149
if data_source is None:
150150
data_source = models.DataSource(
151151
source_type=source_type, source_name=source_name, source_url=source_url
152-
) # type: ignore
152+
)
153153
db.session.add(data_source)
154154
db.session.commit()
155155

@@ -211,7 +211,7 @@ def post(self, files_data, query_data):
211211
record_type="citation",
212212
num_records=n_citations,
213213
status=status,
214-
) # type: ignore
214+
)
215215
db.session.add(citations_import)
216216
db.session.commit()
217217
current_app.logger.info(

colandr/api/v1/routes/citation_screenings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def post(self, id, json_data):
123123
stage="citation",
124124
status=json_data["status"],
125125
exclude_reasons=json_data["exclude_reasons"],
126-
) # type: ignore
126+
)
127127
study.screenings.add(screening)
128128
db.session.commit()
129129

colandr/api/v1/routes/citations.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ def post(self, json_data, query_data):
193193
if data_source is None:
194194
data_source = models.DataSource(
195195
source_type=source_type, source_name=source_name, source_url=source_url
196-
) # type: ignore
196+
)
197197
db.session.add(data_source)
198198
db.session.commit()
199199
current_app.logger.info("%s inserted %s", current_user, data_source)
@@ -206,7 +206,7 @@ def post(self, json_data, query_data):
206206
data_source_id=data_source.id,
207207
# citation=citation,
208208
citation=json_data,
209-
) # type: ignore
209+
)
210210
if status is not None:
211211
study.citation_status = status
212212
db.session.add(study)

colandr/api/v1/routes/data_extractions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def put(self, id, json_data):
108108
)
109109

110110
labels_map = {
111-
item["label"]: (item["field_type"], set(item.get("allowed_values", []))) # type: ignore
111+
item["label"]: (item["field_type"], set(item.get("allowed_values", [])))
112112
for item in data_extraction_form[0]
113113
}
114114
# manually validate inputs, given data extraction form specification

colandr/api/v1/routes/exports.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ def get(self, query_data):
370370
row.citation_status: row.count
371371
for row in db.session.execute(n_citations_by_status_stmt)
372372
}
373-
n_citations_screened = sum(n_citations_by_status.values()) # type: ignore
373+
n_citations_screened = sum(n_citations_by_status.values())
374374
n_citations_excluded = n_citations_by_status.get("excluded", 0)
375375

376376
n_fulltexts_by_status_stmt = (
@@ -383,7 +383,7 @@ def get(self, query_data):
383383
row.fulltext_status: row.count
384384
for row in db.session.execute(n_fulltexts_by_status_stmt)
385385
}
386-
n_fulltexts_screened = sum(n_fulltexts_by_status.values()) # type: ignore
386+
n_fulltexts_screened = sum(n_fulltexts_by_status.values())
387387
n_fulltexts_excluded = n_fulltexts_by_status.get("excluded", 0)
388388

389389
results = db.session.execute(

colandr/api/v1/routes/fulltext_screenings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def post(self, id, json_data):
142142
stage="fulltext",
143143
status=json_data["status"],
144144
exclude_reasons=json_data["exclude_reasons"],
145-
) # type: ignore
145+
)
146146
study.screenings.add(screening)
147147
db.session.commit()
148148

0 commit comments

Comments
 (0)