Skip to content

Commit

Permalink
Good type hint
Browse files Browse the repository at this point in the history
  • Loading branch information
delucchi-cmu committed Sep 25, 2024
1 parent ae05999 commit 9d0e97a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/hats/catalog/dataset/table_properties.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import List, Optional
from pathlib import Path
from typing import List, Optional, Union

from jproperties import Properties
from pydantic import BaseModel, ConfigDict, Field, field_serializer, field_validator, model_validator
Expand Down Expand Up @@ -140,7 +141,7 @@ def __str__(self):
return formatted_string

Check warning on line 141 in src/hats/catalog/dataset/table_properties.py

View check run for this annotation

Codecov / codecov/patch

src/hats/catalog/dataset/table_properties.py#L137-L141

Added lines #L137 - L141 were not covered by tests

@classmethod
def read_from_dir(cls, catalog_dir: UPath) -> Self:
def read_from_dir(cls, catalog_dir: Union[str, Path, UPath]) -> Self:
"""Read field values from a java-style properties file."""
file_path = file_io.get_upath(catalog_dir) / "properties"
if not file_io.does_file_or_directory_exist(file_path):
Expand All @@ -150,7 +151,7 @@ def read_from_dir(cls, catalog_dir: UPath) -> Self:
p.load(f, "utf-8")
return cls(**p.properties)

def to_properties_file(self, catalog_dir: UPath) -> Self:
def to_properties_file(self, catalog_dir: Union[str, Path, UPath]) -> Self:
"""Write fields to a java-style properties file."""
# pylint: disable=protected-access
parameters = self.model_dump(by_alias=True, exclude_none=True)
Expand Down

0 comments on commit 9d0e97a

Please sign in to comment.