Skip to content

Commit

Permalink
Dev (#110)
Browse files Browse the repository at this point in the history
* Chore: update actions/setup-python@v4 to actions/setup-python@v5

* Chore: add ruff

* Chore: remove black deps

* Chore: add ruff deps

* Chore: add ruff

* Fix: add ruff format

* Chore: add ruff and remove black
  • Loading branch information
albertandking authored Mar 31, 2024
1 parent cb16950 commit 80c885d
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 20 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Install tox
run: python -m pip install tox

- name: Run black
- name: Run ruff
run: tox -e format

lint:
Expand All @@ -33,7 +33,7 @@ jobs:
- name: Install tox
run: python -m pip install tox

- name: Run flake8
- name: Run ruff
run: tox -e lint

typecheck:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/schedule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Install tox
run: python -m pip install tox

- name: Run black
- name: Run ruff
run: tox -e format

lint:
Expand All @@ -34,7 +34,7 @@ jobs:
- name: Install tox
run: python -m pip install tox

- name: Run flake8
- name: Run ruff
run: tox -e lint

typecheck:
Expand Down
79 changes: 77 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,81 @@
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"

[tool.black]
[tool.ruff]
# Exclude a variety of commonly ignored directories.
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".git-rewrite",
".hg",
".ipynb_checkpoints",
".mypy_cache",
".nox",
".pants.d",
".pyenv",
".pytest_cache",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
".vscode",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"site-packages",
"venv",
]

# Same as Black.
line-length = 79
target-version = ["py39", "py310", "py311", "py312"]
indent-width = 4

# Assume Python 3.12
target-version = "py312"

[tool.ruff.lint]
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or
# McCabe complexity (`C901`) by default.
select = ["E4", "E7", "E9", "F"]
ignore = []

# Allow fix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
unfixable = []

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

[tool.ruff.format]
# Like Black, use double quotes for strings.
quote-style = "double"

# Like Black, indent with spaces, rather than tabs.
indent-style = "space"

# Like Black, respect magic trailing commas.
skip-magic-trailing-comma = false

# Like Black, automatically detect the appropriate line ending.
line-ending = "auto"

# Enable auto-formatting of code examples in docstrings. Markdown,
# reStructuredText code/literal blocks and doctests are all supported.
#
# This is currently disabled by default, but it is planned for this
# to be opt-out in the future.
docstring-code-format = false

# Set the line length limit used when formatting code snippets in
# docstrings.
#
# This only has an effect when the `docstring-code-format` setting is
# enabled.
docstring-code-line-length = "dynamic"
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
akshare>=1.10.1
alpaca-py>=0.7.2
black>=22.10.0
diskcache>=5.4.0
flake8>=5.0.4
flake8-bugbear>=22.10.25
Expand All @@ -22,4 +21,5 @@ scikit-learn>=1.2.1
Sphinx>=5.3.0
sphinx_rtd_theme>=1.1.1
sphinx-intl>=2.1.0
yfinance>=0.1.84
yfinance>=0.1.84
ruff>=0.3.4
16 changes: 4 additions & 12 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,6 @@ pretty = True
namespace_packages = True
check_untyped_defs = True

[flake8]
per-file-ignores =
src/pybroker/*.py:E203,E402
src/pybroker/__init__.py:F401,E402
tests/*.py:E203,E402
tests/test_*:E203,E402,F403,F405

[tox:tox]
envlist = py39,py310,py311,py312
isolated_build = True
Expand All @@ -70,17 +63,16 @@ commands =
[testenv:format]
skip_install = True
deps =
black
ruff
commands =
black {posargs:--check --diff src tests}
ruff {posargs:--fix src tests}

[testenv:lint]
skip_install = True
deps =
flake8
flake8-bugbear
ruff
commands =
flake8 {posargs:src tests}
ruff {posargs:src tests}

[testenv:docs]
deps =
Expand Down

0 comments on commit 80c885d

Please sign in to comment.