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 and linters configuration #79

Merged
merged 1 commit into from
May 6, 2024
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
6 changes: 6 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,9 @@ jobs:
- run: make -C libfaketime/vendor/libfaketime
if: runner.os == 'macOS'
- run: tox -e ${{ matrix.python }}-${{ matrix.tz }} --recreate

style:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pre-commit/[email protected]
19 changes: 19 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.4.3'
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
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
1 change: 0 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -337,4 +337,3 @@ proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

11 changes: 6 additions & 5 deletions benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
import sys
import time

from freezegun import freeze_time as freezegun_fake_time

from libfaketime import fake_time as lft_fake_time
from libfaketime import reexec_if_needed
from freezegun import freeze_time as freezegun_fake_time


def sample(faker):
Expand All @@ -17,20 +18,20 @@ def sample(faker):

return time.perf_counter() - start

if __name__ == '__main__':

if len(sys.argv) > 1 and sys.argv[1] == 'freezegun':
if __name__ == "__main__":
if len(sys.argv) > 1 and sys.argv[1] == "freezegun":
faker = freezegun_fake_time
else:
faker = lft_fake_time
reexec_if_needed()

iterations = 1000

print("timing %s executions of %s" % (iterations, faker))
print(f"timing {iterations} executions of {faker}")

sum = 0
for _ in range(iterations):
sum += sample(faker)

print(sum, 'seconds')
print(sum, "seconds")
2 changes: 2 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import os

import libfaketime


def pytest_configure():
libfaketime.reexec_if_needed()
_, env_additions = libfaketime.get_reload_information()
Expand Down
Loading
Loading