diff --git a/.coveragerc b/.coveragerc index 3ad2277..06caa1b 100644 --- a/.coveragerc +++ b/.coveragerc @@ -3,5 +3,5 @@ omit = tests/* [report] -exclude_also = +exclude_also = if __name__ == .__main__.: diff --git a/.readthedocs.yaml b/.readthedocs.yaml index b35c772..c542ae6 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -31,5 +31,3 @@ python: install: - method: pip path: .[docs] - - diff --git a/adtl/__init__.py b/adtl/__init__.py index 4880082..bfbc2a6 100644 --- a/adtl/__init__.py +++ b/adtl/__init__.py @@ -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) @@ -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): @@ -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, ) diff --git a/docs/_static/style.css b/docs/_static/style.css index 27cafa6..3bd4c00 100644 --- a/docs/_static/style.css +++ b/docs/_static/style.css @@ -111,4 +111,3 @@ div.bodywrapper h4 { padding-right: 0; } } - diff --git a/docs/adtl.rst b/docs/adtl.rst index 8dd2e4b..d6247f8 100644 --- a/docs/adtl.rst +++ b/docs/adtl.rst @@ -3,4 +3,4 @@ Module reference ===================== .. autoclass:: adtl.Parser - :members: \ No newline at end of file + :members: diff --git a/docs/conf.py b/docs/conf.py index 2cdcbce..993532f 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -38,7 +38,7 @@ 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 = { @@ -46,4 +46,4 @@ "sidebarwidth": "25rem", "cssfiles": ["_static/style.css"], "showheader": False, -} \ No newline at end of file +} diff --git a/docs/getting_started/installation.md b/docs/getting_started/installation.md index 0ab0748..dae4cc9 100644 --- a/docs/getting_started/installation.md +++ b/docs/getting_started/installation.md @@ -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. - diff --git a/docs/index.md b/docs/index.md index da5b831..0bb9afc 100644 --- a/docs/index.md +++ b/docs/index.md @@ -47,4 +47,4 @@ maxdepth: 1 adtl transformations -``` \ No newline at end of file +``` diff --git a/docs/transformations.rst b/docs/transformations.rst index d8c9032..be0c85f 100644 --- a/docs/transformations.rst +++ b/docs/transformations.rst @@ -3,4 +3,4 @@ Transformations ===================== .. automodule:: adtl.transformations - :members: \ No newline at end of file + :members: diff --git a/schemas/dev.schema.json b/schemas/dev.schema.json index c794ca8..3624c12 100644 --- a/schemas/dev.schema.json +++ b/schemas/dev.schema.json @@ -226,4 +226,4 @@ } } } -} \ No newline at end of file +} diff --git a/tests/parsers/epoch-web-schema.json b/tests/parsers/epoch-web-schema.json index 8f58f18..d8c0e66 100644 --- a/tests/parsers/epoch-web-schema.json +++ b/tests/parsers/epoch-web-schema.json @@ -24,4 +24,4 @@ "field": "Text" } } -} \ No newline at end of file +} diff --git a/tests/parsers/epoch.yml b/tests/parsers/epoch.yml index f548dce..283a5bf 100644 --- a/tests/parsers/epoch.yml +++ b/tests/parsers/epoch.yml @@ -8,4 +8,4 @@ table: id: { field: Entry_ID } epoch: { field: Epoch } some_date: { field: SomeDate } - text: { field: Text } \ No newline at end of file + text: { field: Text } diff --git a/tests/parsers/skip_field.json b/tests/parsers/skip_field.json index 97079cc..3998743 100644 --- a/tests/parsers/skip_field.json +++ b/tests/parsers/skip_field.json @@ -31,4 +31,4 @@ "can_skip": true } } -} \ No newline at end of file +} diff --git a/tests/parsers/stop-overwriting.toml b/tests/parsers/stop-overwriting.toml index 7ebdc0b..65d7b4c 100644 --- a/tests/parsers/stop-overwriting.toml +++ b/tests/parsers/stop-overwriting.toml @@ -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 = [ @@ -44,4 +44,3 @@ { field = "overall_antiviral_dc___2", values = { 1 = "Lopinavir" } }, { field = "overall_antiviral_dc___3", values = { 1 = "Interferon" } }, ] - diff --git a/tests/schemas/epoch-data.schema.json b/tests/schemas/epoch-data.schema.json index abdc5f7..8433465 100644 --- a/tests/schemas/epoch-data.schema.json +++ b/tests/schemas/epoch-data.schema.json @@ -29,4 +29,4 @@ "description": "Follow-up cough field" } } -} \ No newline at end of file +} diff --git a/tests/schemas/epoch-oneOf.schema.json b/tests/schemas/epoch-oneOf.schema.json index 2c67d56..4a29d22 100644 --- a/tests/schemas/epoch-oneOf.schema.json +++ b/tests/schemas/epoch-oneOf.schema.json @@ -58,4 +58,4 @@ "description": "sex" } } -} \ No newline at end of file +} diff --git a/tests/schemas/observation_defaultif.schema.json b/tests/schemas/observation_defaultif.schema.json index 525f42c..ba16658 100644 --- a/tests/schemas/observation_defaultif.schema.json +++ b/tests/schemas/observation_defaultif.schema.json @@ -72,4 +72,4 @@ ] } } -} \ No newline at end of file +} diff --git a/tests/sources/oneToMany.csv b/tests/sources/oneToMany.csv index d74ea7b..fff0d1d 100644 --- a/tests/sources/oneToMany.csv +++ b/tests/sources/oneToMany.csv @@ -1,2 +1,2 @@ dt,headache_cmyn,cough_cmyn,dyspnea_cmyn -2022-02-05,1,1,0 \ No newline at end of file +2022-02-05,1,1,0 diff --git a/tests/sources/stop-overwriting.csv b/tests/sources/stop-overwriting.csv index 2455376..a776030 100644 --- a/tests/sources/stop-overwriting.csv +++ b/tests/sources/stop-overwriting.csv @@ -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 \ No newline at end of file +3,day1,,,,1,0,0,0,0,0