Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable ruff rule DTZ003 and DZT004 #6205

Merged
merged 3 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions parsers/ENTSOE.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@

def closest_in_time_key(x, target_datetime: datetime | None, datetime_key="datetime"):
if target_datetime is None:
target_datetime = datetime.utcnow()
target_datetime = datetime.now(timezone.utc)
if isinstance(target_datetime, datetime):
return np.abs((x[datetime_key] - target_datetime).seconds)

Expand All @@ -490,7 +490,7 @@ def query_ENTSOE(
env_var = "ENTSOE_REFETCH_TOKEN"
url = ENTSOE_EU_PROXY_ENDPOINT
if target_datetime is None:
target_datetime = datetime.utcnow()
target_datetime = datetime.now(timezone.utc)
env_var = "ENTSOE_TOKEN"
url = ENTSOE_ENDPOINT

Expand Down
6 changes: 3 additions & 3 deletions parsers/ESKOM.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import csv
from datetime import datetime, timedelta
from datetime import datetime, timedelta, timezone
from logging import Logger, getLogger
from pprint import PrettyPrinter
from zoneinfo import ZoneInfo
Expand Down Expand Up @@ -53,8 +53,8 @@

def get_url() -> str:
"""Returns the formatted URL"""
date = datetime.utcnow()
return f"https://www.eskom.co.za/dataportal/wp-content/uploads/{date.strftime('%Y')}/{date.strftime('%m')}/Station_Build_Up.csv"
date = datetime.now(timezone.utc)
return f"https://www.eskom.co.za/dataportal/wp-content/uploads/{date.strftime('%Y/%m')}/{date.strftime('%m')}/Station_Build_Up.csv"
VIKTORVAV99 marked this conversation as resolved.
Show resolved Hide resolved


def fetch_production(
Expand Down
4 changes: 2 additions & 2 deletions parsers/FR-COR_IT-SAR.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from collections.abc import Callable
from datetime import datetime, timedelta
from datetime import datetime, timedelta, timezone
from logging import Logger, getLogger
from typing import Literal

Expand Down Expand Up @@ -31,7 +31,7 @@ def fetch_data(
type: Literal["exchange", "exchange_forecast"],
) -> list[dict]:
if target_datetime is None:
target_datetime = datetime.utcnow()
target_datetime = datetime.now(timezone.utc)

# IT-SACOAC to IT-SAR
AC_dataList = EXCHANGE_FUNCTION_MAP[type](
Expand Down
4 changes: 2 additions & 2 deletions parsers/NO-NO4_SE.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from collections.abc import Callable
from datetime import datetime, timedelta
from datetime import datetime, timedelta, timezone
from logging import Logger, getLogger
from typing import Literal

Expand Down Expand Up @@ -31,7 +31,7 @@ def fetch_data(
type: Literal["exchange", "exchange_forecast"],
) -> list[dict]:
if target_datetime is None:
target_datetime = datetime.utcnow()
target_datetime = datetime.now(timezone.utc)

# NO-NO4 to SE-SE1
SE1_dataList = EXCHANGE_FUNCTION_MAP[type](
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ target-version = "py310"
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or
# McCabe complexity (`C901`) by default.
select = ["E4", "E7", "E9","E999", "F", "UP", "I"]
select = ["E4", "E7", "E9","E999", "F", "UP", "I", "DTZ003", "DTZ004"]
ignore = []

# Allow fix for all enabled rules (when `--fix`) is provided.
Expand Down