Skip to content

Commit

Permalink
Update types and removed unused imports
Browse files Browse the repository at this point in the history
  • Loading branch information
hija committed Sep 9, 2024
1 parent f030e4c commit f823095
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
6 changes: 3 additions & 3 deletions clean_dotenv/_main.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import os
import argparse
from typing import Iterator, List
from collections.abc import Iterator
import clean_dotenv._parser as DotEnvParser


def _clean_env(path_to_env: str, values_to_keep: List[str] = []):
def _clean_env(path_to_env: str, values_to_keep: list[str] = []):
# Open the .env file and remove the sensitive data
# We rely on python-dotenv to parse the file, since we do not want to write our own parser
dotenv_elements = DotEnvParser.parse_stream(open(path_to_env))
Expand Down Expand Up @@ -44,7 +44,7 @@ def _find_dotenv_files(path_to_root: str) -> Iterator[str]:
yield entry.path


def _main(path_to_root: str, values_to_keep: List[str] = []):
def _main(path_to_root: str, values_to_keep: list[str] = []):
# Find possible .env files
for dotenv_file in _find_dotenv_files(path_to_root):
# Clean dotenv file
Expand Down
11 changes: 4 additions & 7 deletions clean_dotenv/_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,11 @@
import re
from typing import (
IO,
Iterator,
Match,
NamedTuple,
Optional, # noqa:F401
Pattern,
Sequence,
Tuple,
Optional,
)
from collections.abc import Iterator, Sequence
from re import Match, Pattern


def make_regex(string: str, extra_flags: int = 0) -> Pattern[str]:
Expand Down Expand Up @@ -162,7 +159,7 @@ def parse_unquoted_value(reader: Reader) -> str:
return re.sub(r"\s+#.*", "", part).rstrip()


def parse_value(reader: Reader) -> Tuple[str, str]:
def parse_value(reader: Reader) -> tuple[str, str]:
char = reader.peek(1)
if char == "'":
(value,) = reader.read_regex(_single_quoted_value)
Expand Down

0 comments on commit f823095

Please sign in to comment.