Skip to content

Commit

Permalink
Add linting to examples, fix type hints for empty dicts and list args.
Browse files Browse the repository at this point in the history
  • Loading branch information
Schalk1e committed Oct 3, 2024
1 parent 736a288 commit eeff1a0
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .ci/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ lint() {
return $failed
}

lint rdw_ingestion_tools/
lint rdw_ingestion_tools/ examples/
result=$?

if [ $result = 0 ]; then
Expand Down
2 changes: 0 additions & 2 deletions examples/mqr/mqr.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from datetime import datetime

from api.survey import pySurvey

start = "2023-01-01T00:00:00"
Expand Down
4 changes: 2 additions & 2 deletions examples/s3_utils/unify.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""
Usage example: pr python3 examples/s3_utils/unify.py --bucket 'rdw-za' --prefix 'contact-ndoh/momconnect-flow-results/flows/questions/'
Usage example: pr python3 examples/s3_utils/unify.py --bucket 'rdw-za' --prefix
'contact-ndoh/momconnect-flow-results/flows/questions/'
"""

import argparse
import os

from pandas import concat
from s3 import pyS3
Expand Down
2 changes: 1 addition & 1 deletion examples/turn_bq/flow_results_data_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

print(flow_results_data_packages.head(5))

flow_results_data_packages = pyTurnBQ.flow_results_data_packages.get_flow_results_data_packages_by_updated_at(
flow_results_data_packages = pyTurnBQ.flow_results_data_packages.get_flow_results_data_packages_by_updated_at( # noqa: E501
from_timestamp="2023-10-01T00:00:00", to_timestamp="2023-10-10T00:00:00"
)

Expand Down
13 changes: 12 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pandas = "^2.2.2"
awswrangler = "^3.7.3"
attrs = "^23.2.0"
httpx = "^0.27.0"
types-tqdm = "^4.66.0.20240417"

[tool.poetry.group.types.dependencies]
pandas-stubs = "^2.2.1.240316"
Expand Down
7 changes: 6 additions & 1 deletion rdw_ingestion_tools/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

from pandas import DataFrame, concat, json_normalize

# https://github.com/astral-sh/ruff/issues/3388
from typing_extensions import Never # noqa: UP035


class MissingConfig(Exception):
"""Raised if a required config environment variable is not set."""
Expand All @@ -18,7 +21,9 @@ def config_from_env(key: str) -> str:
return value


def concatenate(objs: list[dict] | dict | list | Iterator) -> DataFrame:
def concatenate(
objs: list[dict] | dict[Never, Never] | list[Never] | Iterator,
) -> DataFrame:
"""
Extend pandas concat to not only support dicts or lists of dicts, but
also empty lists (which is often returned by the APIs).
Expand Down

0 comments on commit eeff1a0

Please sign in to comment.