Skip to content

Commit

Permalink
darglint cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
aecorn committed Feb 23, 2024
1 parent d836b8d commit 08b5a92
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 19 deletions.
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Sphinx configuration."""

# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
Expand Down
1 change: 1 addition & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Nox sessions."""

import os
import shlex
import shutil
Expand Down
1 change: 1 addition & 0 deletions src/statbank/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Used internally by SSB (Statistics Norway).
"""

from __future__ import annotations

import datetime as dt
Expand Down
4 changes: 2 additions & 2 deletions src/statbank/apidata.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def apidata(
Args:
id_or_url (str): The id of the STATBANK-table to get the total query for, or supply the total url, if the table is "internal".
payload (QueryWholeType): a dict in the shape of a QueryWhole, to include with the request, can be copied from the statbank-webpage.
payload (QueryWholeType | None): a dict in the shape of a QueryWhole, to include with the request, can be copied from the statbank-webpage.
include_id (bool): If you want to include "codes" in the dataframe, set this to True
Returns:
Expand Down Expand Up @@ -101,7 +101,7 @@ def apidata_query_all(id_or_url: str = "") -> QueryWholeType:
id_or_url (str): The id of the STATBANK-table to get the total query for, or supply the total url, if the table is "internal".
Returns:
dict: The prepared query based on all the codes in the table.
QueryWholeType: The prepared query based on all the codes in the table.
"""
if len(id_or_url) == STATBANK_TABLE_ID_LENGTH and id_or_url.isdigit():
url = f"https://data.ssb.no/api/v0/no/table/{id_or_url}/"
Expand Down
2 changes: 1 addition & 1 deletion src/statbank/transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def transfer(self, headers: dict[str, str] | None = None) -> None:
Will only work if the transfer has not already been sent, meaning it was "delayed".
Args:
headers (dict[str, str]): Mostly for internal use by the package.
headers (dict[str, str] | None): Mostly for internal use by the package.
Needs to be a finished compiled headers for a request including Authorization.
"""
# In case transfer has already happened, dont transfer again
Expand Down
12 changes: 7 additions & 5 deletions src/statbank/uttrekk.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
from __future__ import annotations

import copy
Expand Down Expand Up @@ -213,7 +212,10 @@ def validate(
raise_errors (bool): True/False based on if you want the method to raise its own errors or not.
Returns:
dict[str, Exception]: A dictionary of the errors the validation wants to raise.
dict[str, ValueError]: A dictionary of the errors the validation wants to raise.
Raises:
StatbankValidateError: if raise_errors is set to True and there are validation errors.
"""
if not raise_errors:
raise_errors = self.raise_errors
Expand Down Expand Up @@ -378,9 +380,9 @@ def _split_attributes(self) -> None:
new_kodeliste[kode["kode"]] = kode["text"]
self.codelists[kodeliste["kodeliste"]] = {"koder": new_kodeliste}
if "SumIALtTotalKode" in kodeliste:
self.codelists[kodeliste["kodeliste"]][
"SumIALtTotalKode"
] = kodeliste["SumIALtTotalKode"]
self.codelists[kodeliste["kodeliste"]]["SumIALtTotalKode"] = (
kodeliste["SumIALtTotalKode"]
)

if "null_prikk_missing_kodeliste" in self.filbeskrivelse:
self.suppression = self.filbeskrivelse["null_prikk_missing_kodeliste"]
20 changes: 10 additions & 10 deletions src/statbank/uttrekk_validations.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ def _check_for_literal_nans_in_strings(
Maybe with a .fillna("") before an .astype(str) """
nan_len = len(string_df[string_df[col].str.lower().isin(nans)])
if nan_len:
validation_errors[
f"contains_string_nans_{name}_{col}"
] = ValueError(error_text)
validation_errors[f"contains_string_nans_{name}_{col}"] = (
ValueError(error_text)
)
logger.warning(error_text)
if len(cat_df.columns):
for col in cat_df.columns:
Expand Down Expand Up @@ -259,10 +259,10 @@ def _check_time_columns(
if specials:
for i, special in specials.items():
if not all(data[deltabell_name].iloc[:, col_num].str[i] == special):
validation_errors[
f"special_character_match_column{col_num}"
] = ValueError(
f"Should be the special character {special}, character number {num} in column {col_num} in DataFrame {deltabell_name}, does not match format {timeformat_raw}",
validation_errors[f"special_character_match_column{col_num}"] = (
ValueError(
f"Should be the special character {special}, character number {num} in column {col_num} in DataFrame {deltabell_name}, does not match format {timeformat_raw}",
)
)
return validation_errors

Expand Down Expand Up @@ -487,8 +487,8 @@ def _check_rounding(
data = uttrekksbeskrivelse.round_data(data),
this rounds UP like SAS and Excel, not to-even as
Python does otherwise."""
validation_errors[
f"rounding_error_{deltabell_name}_{col_num}"
] = ValueError(error_text)
validation_errors[f"rounding_error_{deltabell_name}_{col_num}"] = (
ValueError(error_text)
)
logger.warning(error_text)
return validation_errors
1 change: 0 additions & 1 deletion tests/test_statbank.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
from __future__ import annotations

import json
Expand Down

0 comments on commit 08b5a92

Please sign in to comment.