Skip to content
Merged
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
29 changes: 29 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: "Check formatting and linting"

on:
push:
pull_request:
workflow_dispatch:

permissions:
contents: read

jobs:
check:
name: "just check"
runs-on: ubuntu-24.04

steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- uses: opensafely-core/setup-action@d9171097dd0d37bdb7bed58f701eb03ff317ed17 # v1.7.0
with:
python-version: "3.11"
install-just: true
install-uv: true
cache: uv

- name: Check formatting, linting, and import sorting
run: just check
5 changes: 3 additions & 2 deletions docs/actions-reusable.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,11 @@ Where *action/cli.py* is:

```python
def main():
print("A reusable action")
print("A reusable action")


if __name__ == "__main__":
main()
main()
```

When developing a reusable action, just as when developing a scripted action, the action's dependencies are made available by the runtime; they are not made available by the action.
Expand Down
26 changes: 14 additions & 12 deletions docs/case-control-studies.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,16 +175,17 @@ from ehrql import table_from_file
CONTROLS = "output/matched_matches.arrow"

matched_patients = table_from_file(
CONTROLS,
columns={
"age": int,
"sex": str,
"index_date": datetime.date
}
CONTROLS,
columns={
"age": int,
"sex": str,
"index_date": datetime.date,
},
)
```

This allows us to only include the matched controls in our dataset.
<!-- fmt:off -->
```python
from ehrql import create_dataset

Expand All @@ -193,6 +194,7 @@ dataset.define_population(
matched_patients.exists_for_patient()
)
```
<!-- fmt:on -->
Don't forget to add additional population constraints to the dataset if you require them!

The `index_date` column in `matched_patients` is the date generated by the matching process,
Expand Down Expand Up @@ -225,12 +227,12 @@ CONTROLS = "output/matched_matches.arrow"
codelist = codelist_from_csv("codelists/codelist.csv")

matched_patients = table_from_file(
CONTROLS,
columns={
"age": int,
"sex": str,
"index_date": datetime.date
}
CONTROLS,
columns={
"age": int,
"sex": str,
"index_date": datetime.date,
},
)

dataset = create_dataset()
Expand Down
21 changes: 11 additions & 10 deletions docs/federation.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,17 @@ For example, this section of the study definition creates a variable that indica


```python

sev_obesity = patients.with_these_clinical_events(
sev_obesity_codes,
returning = "date",
ignore_missing_values = True,
find_last_match_in_period = True,
on_or_after = "bmi_stage_date",
on_or_before = "index_date",
date_format = "YYYY-MM-DD",
),
sev_obesity = (
patients.with_these_clinical_events(
sev_obesity_codes,
returning="date",
ignore_missing_values=True,
find_last_match_in_period=True,
on_or_after="bmi_stage_date",
on_or_before="index_date",
date_format="YYYY-MM-DD",
),
)
```


Expand Down
2 changes: 1 addition & 1 deletion hooks/ehrql_branch.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def on_config(config):
ehrql_nav_index, ehrql_nav_section = next(
(i, section)
for i, section in enumerate(config["nav"])
if list(section.keys())[0] == "ehrQL"
if next(iter(section.keys())) == "ehrQL"
)
new_import_string = ehrql_nav_section["ehrQL"].replace(
"branch=main", f"branch={ehrql_branch}"
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ exclude = [
"docker",
"htmlcov",
"venv",
# These are frozen and we don't intend to update them
"docs/legacy",
]

[tool.ruff.lint]
Expand Down
Empty file added scripts/__init__.py
Empty file.
4 changes: 2 additions & 2 deletions scripts/wordcount.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from html.parser import HTMLParser
import sys
from html.parser import HTMLParser


class ArticleParser(HTMLParser):
Expand All @@ -24,7 +24,7 @@ def handle_data(self, data):
if __name__ == "__main__":
total = 0
for filename in sys.argv[1:]:
with open(filename, "r", encoding="utf-8") as f:
with open(filename, encoding="utf-8") as f:
parser = ArticleParser()
parser.feed(f.read())
text = " ".join(parser.text)
Expand Down
Loading