Skip to content

Commit

Permalink
Enable ruff DTZ001 rule (TheAlgorithms#11326)
Browse files Browse the repository at this point in the history
* updating DIRECTORY.md

* Enable ruff DTZ001 rule

* Fix other/gauss_easter.py

* Fix

* Fix

* Fix

* Fix

* Fix

* Fix

---------

Co-authored-by: MaximSmolskiy <MaximSmolskiy@users.noreply.github.com>
  • Loading branch information
MaximSmolskiy and MaximSmolskiy authored Mar 25, 2024
1 parent 481c071 commit 102e9a3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 2 additions & 0 deletions DIRECTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@
* [Koch Snowflake](fractals/koch_snowflake.py)
* [Mandelbrot](fractals/mandelbrot.py)
* [Sierpinski Triangle](fractals/sierpinski_triangle.py)
* [Vicsek](fractals/vicsek.py)

## Fuzzy Logic
* [Fuzzy Operations](fuzzy_logic/fuzzy_operations.py)
Expand Down Expand Up @@ -678,6 +679,7 @@
* [Newton Forward Interpolation](maths/numerical_analysis/newton_forward_interpolation.py)
* [Newton Raphson](maths/numerical_analysis/newton_raphson.py)
* [Numerical Integration](maths/numerical_analysis/numerical_integration.py)
* [Proper Fractions](maths/numerical_analysis/proper_fractions.py)
* [Runge Kutta](maths/numerical_analysis/runge_kutta.py)
* [Runge Kutta Fehlberg 45](maths/numerical_analysis/runge_kutta_fehlberg_45.py)
* [Runge Kutta Gills](maths/numerical_analysis/runge_kutta_gills.py)
Expand Down
16 changes: 8 additions & 8 deletions other/gauss_easter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@
"""

import math
from datetime import datetime, timedelta
from datetime import UTC, datetime, timedelta


def gauss_easter(year: int) -> datetime:
"""
Calculation Gregorian easter date for given year
>>> gauss_easter(2007)
datetime.datetime(2007, 4, 8, 0, 0)
datetime.datetime(2007, 4, 8, 0, 0, tzinfo=datetime.timezone.utc)
>>> gauss_easter(2008)
datetime.datetime(2008, 3, 23, 0, 0)
datetime.datetime(2008, 3, 23, 0, 0, tzinfo=datetime.timezone.utc)
>>> gauss_easter(2020)
datetime.datetime(2020, 4, 12, 0, 0)
datetime.datetime(2020, 4, 12, 0, 0, tzinfo=datetime.timezone.utc)
>>> gauss_easter(2021)
datetime.datetime(2021, 4, 4, 0, 0)
datetime.datetime(2021, 4, 4, 0, 0, tzinfo=datetime.timezone.utc)
"""
metonic_cycle = year % 19
julian_leap_year = year % 4
Expand All @@ -45,11 +45,11 @@ def gauss_easter(year: int) -> datetime:
) % 7

if days_to_add == 29 and days_from_phm_to_sunday == 6:
return datetime(year, 4, 19)
return datetime(year, 4, 19, tzinfo=UTC)
elif days_to_add == 28 and days_from_phm_to_sunday == 6:
return datetime(year, 4, 18)
return datetime(year, 4, 18, tzinfo=UTC)
else:
return datetime(year, 3, 22) + timedelta(
return datetime(year, 3, 22, tzinfo=UTC) + timedelta(
days=int(days_to_add + days_from_phm_to_sunday)
)

Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
lint.ignore = [ # `ruff rule S101` for a description of that rule
"B904", # Within an `except` clause, raise exceptions with `raise ... from err` -- FIX ME
"B905", # `zip()` without an explicit `strict=` parameter -- FIX ME
"DTZ001", # The use of `datetime.datetime()` without `tzinfo` argument is not allowed -- FIX ME
"DTZ005", # The use of `datetime.datetime.now()` without `tzinfo` argument is not allowed -- FIX ME
"E741", # Ambiguous variable name 'l' -- FIX ME
"EM101", # Exception must not use a string literal, assign to variable first
Expand Down

0 comments on commit 102e9a3

Please sign in to comment.