Skip to content

Commit

Permalink
Remove requirement pytz and use zoneinfo to validate timezone
Browse files Browse the repository at this point in the history
  • Loading branch information
robbertbos committed Mar 22, 2023
1 parent 157df84 commit dd2fb69
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions askanna/core/utils/validate.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
try:
import zoneinfo
except ImportError:
from backports import zoneinfo
from typing import Dict, List, Union

import click
import croniter
import pytz
from email_validator import EmailNotValidError, validate_email
from tzlocal import get_localzone

Expand Down Expand Up @@ -243,7 +246,7 @@ def validate_askanna_yml(config):
global_timezone = config.get("timezone")
# validate the global timezone
if global_timezone:
if global_timezone not in pytz.all_timezones:
if global_timezone not in zoneinfo.available_timezones():
click.echo(
"Invalid timezone setting found in askanna.yml:\n" + f"timezone: {global_timezone}",
err=True,
Expand Down Expand Up @@ -286,7 +289,7 @@ def validate_askanna_yml(config):
return False
# validate the timezone if set
timezone = job.get("timezone")
if timezone and timezone not in pytz.all_timezones:
if timezone and timezone not in zoneinfo.available_timezones():
click.echo(
f"Invalid timezone setting found in job `{jobname}`:\n" + f"timezone: {timezone}",
err=True,
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ keywords = [
"versioncontrol",
]
dependencies = [
"backports.zoneinfo>=0.2.1; python_version < '3.9'",
"click>=7.1.2,<9.0.0",
"cookiecutter>1.7.0,<3.0.0",
"croniter>=1.0.15,<2.0.0",
Expand All @@ -47,7 +48,6 @@ dependencies = [
"igittigitt>=2.0.2,<3.0.0",
"python-dateutil>=2.8.0,<3.0.0",
"python-slugify>=7.0.0,<9.0.0",
"pytz>=2021,<2023",
"PyYAML>=5.3.1,<7.0.0",
"requests>=2.22.0,<3.0.0",
"resumable~=0.1.1",
Expand Down

0 comments on commit dd2fb69

Please sign in to comment.