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

pre-commit update #86

Merged
merged 1 commit into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 2 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
---
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.4.3'
rev: 'v0.8.5'
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: fix-byte-order-marker
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-toml
- repo: https://github.com/PyCQA/docformatter
rev: v1.7.5
hooks:
- id: docformatter
5 changes: 2 additions & 3 deletions libfaketime/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ def get_reload_information():

def main(): # pragma: nocover
"""Print the necessary environment to stdout."""

_, _env_additions = get_reload_information()
for key, value in _env_additions.items():
print(f'export {key}="{value}"')
Expand All @@ -109,12 +108,12 @@ def reexec_if_needed(remove_vars=True, quiet=False):


def begin_callback(instance):
"""Called just before faking the time."""
"""Execute custom code just before faking the time."""
pass


def end_callback(instance):
"""Called just after finished faking the time."""
"""Execute custom code after finished faking the time."""
pass


Expand Down
15 changes: 14 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
[tool.ruff.lint]
select = [
"D", # pydocstyle
"E", # pycodestyle
"F", # pyflakes
"I", # isort
"UP", # pyupgrade
]
ignore = [
"D100", # public module
"D101", # public class
"D102", # public method
"D103", # public function
"D104", # public package
"D105", # magic method
"D106", # nested class
"D107", # public init
"D203", # no-blank-line-before-class
"D213", # multi-line-summary-second-line
]

[tool.ruff.lint.isort]
force-single-line = true

[too.ruff.format]
[tool.ruff.format]
docstring-code-format = true
6 changes: 4 additions & 2 deletions test/test_faketime.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,10 @@ def test_timestmap_file(self, tmpdir):
class TestUUID1Deadlock:
@fake_time(datetime.datetime.now())
def test_uuid1_does_not_deadlock(self):
"""This test will deadlock if we fail to patch a system level uuid
library."""
"""Check the compatibility of uuid1.

This test will deadlock if we fail to patch a system level uuid library.
"""
for i in range(100):
uuid.uuid1()

Expand Down
13 changes: 9 additions & 4 deletions test/test_tz.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@


def test_timezone_is_restored_after_context_manager_usage():
"""https://github.com/simon-weber/python-libfaketime/issues/43"""
"""Check that timezones are restored when faketime context manager are closed.

https://github.com/simon-weber/python-libfaketime/issues/43
"""
now1 = datetime.datetime.now()
utcnow1 = datetime.datetime.utcnow()

Expand Down Expand Up @@ -37,8 +40,7 @@ def test_tzinfo_is_normalized():


def test_block_setting_of_conflicting_tz_info():
"""Cannot pass in tz_offset when the timestamp already carries a
timezone."""
"""Cannot pass in tz_offset when the timestamp already carries a timezone."""
with pytest.raises(Exception) as exc_info:
timezone_to_test_with = timezone("America/Havana")
time_to_freeze = timezone_to_test_with.localize(
Expand All @@ -55,7 +57,10 @@ def test_block_setting_of_conflicting_tz_info():

@pytest.mark.parametrize("offset", range(-2, 3))
def test_generated_tz_is_valid(offset):
"""https://github.com/simon-weber/python-libfaketime/issues/46"""
"""Check that generated timezones are valid.

https://github.com/simon-weber/python-libfaketime/issues/46
"""
now = datetime.datetime.now()

with fake_time(now, tz_offset=offset):
Expand Down
Loading