Skip to content

Commit

Permalink
chore: add pyright, ruff and ruff format to pre-commit (#1487)
Browse files Browse the repository at this point in the history
  • Loading branch information
pcriadoperez authored Dec 2, 2024
1 parent 39bbd87 commit d043588
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
18 changes: 18 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.1
hooks:
- id: ruff
- id: ruff-format

- repo: https://github.com/RobertCraigie/pyright-python
rev: v1.1.389
hooks:
- id: pyright
4 changes: 3 additions & 1 deletion examples/save_historical_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ def date_to_milliseconds(date_str):
:type date_str: str
"""
# get epoch value in UTC
assert date_str is not None
epoch = datetime.utcfromtimestamp(0).replace(tzinfo=pytz.utc)
# parse our date string
d = dateparser.parse(date_str)
assert d is not None
# if the date is not timezone aware apply UTC timezone
if d.tzinfo is None or d.tzinfo.utcoffset(d) is None:
d = d.replace(tzinfo=pytz.utc)
Expand Down Expand Up @@ -82,7 +84,7 @@ def get_historical_klines(symbol, interval, start_str, end_str=None):

# convert interval to useful value in seconds
timeframe = interval_to_milliseconds(interval)

assert timeframe is not None
# convert our date strings to milliseconds
start_ts = date_to_milliseconds(start_str)

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
setup(
name="python-binance",
version=version,
packages=find_packages(exclude=['tests', 'examples']),
packages=find_packages(exclude=["tests", "examples"]),
description="Binance REST API python implementation",
long_description=long_description,
long_description_content_type="text/x-rst",
Expand Down
1 change: 1 addition & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ requests-mock
tox
setuptools
aioresponses
pre-commit

0 comments on commit d043588

Please sign in to comment.