Skip to content

Commit

Permalink
Merge pull request #79 from azmeuk/pre-commit
Browse files Browse the repository at this point in the history
pre-commit and linters configuration
  • Loading branch information
simon-weber committed May 6, 2024
2 parents aa13def + d64efb6 commit 32f39aa
Show file tree
Hide file tree
Showing 15 changed files with 248 additions and 174 deletions.
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

0 comments on commit 32f39aa

Please sign in to comment.