Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jun 24, 2024
1 parent 0bec3ed commit 04e35de
Show file tree
Hide file tree
Showing 19 changed files with 37 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ omit =
tests/*

[report]
exclude_also =
exclude_also =
if __name__ == .__main__.:
2 changes: 0 additions & 2 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,3 @@ python:
install:
- method: pip
path: .[docs]


34 changes: 20 additions & 14 deletions adtl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,14 @@ def get_value_unhashed(row: StrDict, rule: Rule, ctx: Context = None) -> Any:
params.append(row[rule["apply"]["params"][i][1:]])
elif isinstance(rule["apply"]["params"][i], list):
param = [
row[rule["apply"]["params"][i][j][1:]]
if (
isinstance(rule["apply"]["params"][i][j], str)
and rule["apply"]["params"][i][j].startswith("$")
(
row[rule["apply"]["params"][i][j][1:]]
if (
isinstance(rule["apply"]["params"][i][j], str)
and rule["apply"]["params"][i][j].startswith("$")
)
else rule["apply"]["params"][i][j]
)
else rule["apply"]["params"][i][j]
for j in range(len(rule["apply"]["params"][i]))
]
params.append(param)
Expand Down Expand Up @@ -590,9 +592,11 @@ def ctx(self, attribute: str):
"defaultDateFormat": self.header.get(
"defaultDateFormat", DEFAULT_DATE_FORMAT
),
"skip_pattern": re.compile(self.header.get("skipFieldPattern"))
if self.header.get("skipFieldPattern")
else False,
"skip_pattern": (
re.compile(self.header.get("skipFieldPattern"))
if self.header.get("skipFieldPattern")
else False
),
}

def validate_spec(self):
Expand Down Expand Up @@ -793,12 +797,14 @@ def parse(self, file: str, encoding: str = "utf-8", skip_validation=False):
with open(file, encoding=encoding) as fp:
reader = csv.DictReader(fp)
return self.parse_rows(
tqdm(
reader,
desc=f"[{self.name}] parsing {Path(file).name}",
)
if not self.quiet
else reader,
(
tqdm(
reader,
desc=f"[{self.name}] parsing {Path(file).name}",
)
if not self.quiet
else reader
),
skip_validation=skip_validation,
)

Expand Down
1 change: 0 additions & 1 deletion docs/_static/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,3 @@ div.bodywrapper h4 {
padding-right: 0;
}
}

2 changes: 1 addition & 1 deletion docs/adtl.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ Module reference
=====================

.. autoclass:: adtl.Parser
:members:
:members:
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@

html_theme = "better"
html_static_path = ["_static"]
html_theme_path=[better.better_theme_path]
html_theme_path = [better.better_theme_path]
html_short_title = "Home"

html_theme_options = {
"rightsidebar": True,
"sidebarwidth": "25rem",
"cssfiles": ["_static/style.css"],
"showheader": False,
}
}
1 change: 0 additions & 1 deletion docs/getting_started/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,3 @@ If you are writing code which depends on adtl (instead of using
the command-line program), then it is best to add a dependency on
`git+https://github.com/globaldothealth/adtl` to your Python build tool of
choice.

2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ maxdepth: 1
adtl
transformations
```
```
2 changes: 1 addition & 1 deletion docs/transformations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ Transformations
=====================

.. automodule:: adtl.transformations
:members:
:members:
2 changes: 1 addition & 1 deletion schemas/dev.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -226,4 +226,4 @@
}
}
}
}
}
2 changes: 1 addition & 1 deletion tests/parsers/epoch-web-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
"field": "Text"
}
}
}
}
2 changes: 1 addition & 1 deletion tests/parsers/epoch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ table:
id: { field: Entry_ID }
epoch: { field: Epoch }
some_date: { field: SomeDate }
text: { field: Text }
text: { field: Text }
2 changes: 1 addition & 1 deletion tests/parsers/skip_field.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@
"can_skip": true
}
}
}
}
5 changes: 2 additions & 3 deletions tests/parsers/stop-overwriting.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
[visit.subject_id]
field = "subjid"
description = "Subject ID"

[visit.earliest_admission]
combinedType = "min"
fields = [
{ field = "first_admit" },
]

[visit.start_date]
combinedType = "firstNonNull"
fields = [
Expand All @@ -44,4 +44,3 @@
{ field = "overall_antiviral_dc___2", values = { 1 = "Lopinavir" } },
{ field = "overall_antiviral_dc___3", values = { 1 = "Interferon" } },
]

2 changes: 1 addition & 1 deletion tests/schemas/epoch-data.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@
"description": "Follow-up cough field"
}
}
}
}
2 changes: 1 addition & 1 deletion tests/schemas/epoch-oneOf.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@
"description": "sex"
}
}
}
}
2 changes: 1 addition & 1 deletion tests/schemas/observation_defaultif.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@
]
}
}
}
}
2 changes: 1 addition & 1 deletion tests/sources/oneToMany.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
dt,headache_cmyn,cough_cmyn,dyspnea_cmyn
2022-02-05,1,1,0
2022-02-05,1,1,0
2 changes: 1 addition & 1 deletion tests/sources/stop-overwriting.csv
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ subjid,redcap,first_admit,enrolment,icu_admission_date,daily_antiviral_type___1,
2,day1,,,2020-11-30,0,1,0,0,0,0
3,admit,,2020-02-20,,0,0,0,0,0,0
3,discharge,,,,0,0,0,0,1,1
3,day1,,,,1,0,0,0,0,0
3,day1,,,,1,0,0,0,0,0

0 comments on commit 04e35de

Please sign in to comment.