Skip to content

Commit

Permalink
feat: improve type hints
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinBernstorff committed Apr 19, 2023
1 parent bcff7a2 commit d53e61e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cruft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@ jobs:
title: "ci - update cruft"
branch: "update-cruft"
body: "🌲 Cruft updates"
token: ${{ secrets.PAT }}
token: ${{ secrets.PAT }}
commit-message: "ci: update cruft"
labels: "dependencies" # This makes the PR exempt from the stale bot
7 changes: 3 additions & 4 deletions src/timeseriesflattener/feature_cache/cache_to_disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import datetime as dt
import os
from pathlib import Path
from typing import Optional

import pandas as pd

Expand All @@ -17,7 +16,7 @@ class DiskCache(FeatureCache):
def __init__(
self,
feature_cache_dir: Path,
prediction_times_df: Optional[pd.DataFrame] = None,
prediction_times_df: pd.DataFrame,
pred_time_uuid_col_name: str = "pred_time_uuid",
entity_id_col_name: str = "entity_id",
timestamp_col_name: str = "timestamp",
Expand Down Expand Up @@ -131,7 +130,7 @@ def read_feature(self, feature_spec: TemporalSpec) -> pd.DataFrame:

# Replace NaNs with fallback
df[feature_spec.get_col_str()] = df[feature_spec.get_col_str()].fillna(
feature_spec.fallback,
feature_spec.fallback, # type: ignore
)

return df
Expand All @@ -145,7 +144,7 @@ def write_feature(
file_name = self._get_file_name(feature_spec=feature_spec)

# Drop rows containing fallback, since it's non-informative
df = df[df[feature_spec.get_col_str()] != feature_spec.fallback].dropna()
df = df[df[feature_spec.get_col_str()] != feature_spec.fallback].dropna() # type: ignore

# Drop entity and timestamp columns if they exists
for col in [self.entity_entity_id_col_name, self.timestamp_col_name]:
Expand Down
6 changes: 3 additions & 3 deletions src/timeseriesflattener/feature_spec_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ class Doc:
description="""Optional kwargs for the values_loader.""",
)

values_df: Optional[pd.DataFrame] = Field(
values_df: Optional[pd.DataFrame] = Field( # type: ignore
default=None,
description="Dataframe with the values.",
)
Expand Down Expand Up @@ -778,8 +778,8 @@ class Doc:

def _check_loaders_are_valid(self):
"""Check that all loaders can be resolved from the data_loaders catalogue."""
invalid_loaders = list(
set(self.values_loader) - set(data_loaders.get_all().keys()),
invalid_loaders: list = list(
set(self.values_loader) - set(data_loaders.get_all().keys()), # type: ignore
)
if len(invalid_loaders) != 0:
# New line variable as f-string can't handle backslashes
Expand Down

0 comments on commit d53e61e

Please sign in to comment.