Skip to content

Commit

Permalink
add py.typed marker
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-oleshkevich committed Oct 8, 2022
1 parent 7548a70 commit d6afae8
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tool.poetry]
name = "starlette_babel"
description = "Locale support for Starlette"
version = "0.1.0"
version = "0.1.1"
authors = ["Alex Oleshkevich <[email protected]>"]
license = "MIT"
readme = "README.md"
Expand Down
Empty file added starlette_babel/py.typed
Empty file.
2 changes: 1 addition & 1 deletion starlette_babel/translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def load_from_directory(self, directory: str | os.PathLike[str]) -> None:
for locale in os.listdir(directory):
locale_path = os.path.join(directory, locale)
if os.path.isfile(locale_path):
if locale_path.endswith(".pot"):
if locale_path.endswith(".pot") or os.path.basename(locale_path).startswith("."):
continue
raise ValueError(f"Not a locale directory: {locale_path}. It is a file.")

Expand Down
Empty file.
5 changes: 5 additions & 0 deletions tests/test_translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ def test_load_from_directory_should_not_raise_for_pot_files() -> None:
assert True


def test_load_from_directory_should_not_raise_for_dot_files() -> None:
Translator(directories=[BROKEN_LOCALE_DIR / "dotfile"])
assert True


def test_load_from_directory_should_raise_is_lc_messages_missing() -> None:
with pytest.raises(FileNotFoundError):
Translator(directories=[BROKEN_LOCALE_DIR / "no_lc_messages"])
Expand Down

0 comments on commit d6afae8

Please sign in to comment.