diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..e71ddd86 --- /dev/null +++ b/.pre-commit-config.yaml @@ -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 diff --git a/examples/save_historical_data.py b/examples/save_historical_data.py index 1865d098..c3360221 100644 --- a/examples/save_historical_data.py +++ b/examples/save_historical_data.py @@ -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) @@ -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) diff --git a/setup.py b/setup.py index 0f89400f..44fa87b2 100644 --- a/setup.py +++ b/setup.py @@ -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", diff --git a/test-requirements.txt b/test-requirements.txt index a787f1d0..ec3e381a 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -8,3 +8,4 @@ requests-mock tox setuptools aioresponses +pre-commit