Skip to content

Commit

Permalink
Add ruff rules
Browse files Browse the repository at this point in the history
  • Loading branch information
cjdsellers committed Mar 11, 2023
1 parent 854c207 commit af3a720
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 38 deletions.
33 changes: 0 additions & 33 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,6 @@ repos:
##############################################################################
# Python/Cython formatting and linting
##############################################################################
- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
hooks:
- id: pyupgrade
name: pyupgrade (ensure latest syntax)
args: ["--py39-plus"]

- repo: https://github.com/hadialqattan/pycln
rev: v2.1.3
hooks:
Expand Down Expand Up @@ -128,33 +121,7 @@ repos:
hooks:
- id: ruff

- repo: https://github.com/pycqa/pydocstyle
rev: 6.3.0
hooks:
- id: pydocstyle
files: ^nautilus_trader/
exclude: "nautilus_trader/test_kit"
args:
- "--ignore=D100,D102,D103,D104,D107,D105,D200,D203,D205,D212,D400,D413,D415,D416"
additional_dependencies:
- toml

- repo: https://github.com/kynan/nbstripout
rev: 0.6.1
hooks:
- id: nbstripout

# pydocstyle ignore reasons
# -------------------------
# D100: Missing docstring in public module **fix**
# D102: Missing docstring in public method **fix**
# D103: Missing docstring in public function **fix**
# D104: Missing docstring in public package **fix**
# D200: One-line docstring should fit on one line with quotes (optional style)
# D203: 1 blank line required before class docstring (optional style)
# D205: 1 blank line required between summary line and description (optional style)
# D212: Multi-line docstring summary should start at the first line (optional style)
# D400: First line should end with a period (not always a first line)
# D413: Missing blank line after last section ('Parameters')
# D415: First line should end with a period, question mark, or exclamation point (not always a first line)
# D416: Section name should end with a colon ('Warnings:', not 'Warnings') (incorrect?)
66 changes: 63 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,69 @@ line_length = 100
# Linter configs #
##########################################################
[tool.ruff]
# Enable pycodestyle (`E`) and Pyflakes (`F`) codes by default
select = ["E", "F"]
ignore = ["E741"]
select = [
"E",
"F",
"W",
"C90",
"D",
"UP",
"S",
"T10",
"ICN",
"PYI",
"Q",
# "RSE",
"TID",
# "ARG",
# "ERA",
# "PD",
# "PGH",
# "PL",
# "PLE",
# "PLR",
# "PLW",
# "NPY",
# "RUF",
]

ignore = [
"E741",
"D100",
"D101",
"D102",
"D103",
"D104",
"D107",
"D105",
"D200",
"D203",
"D205",
"D212",
"D400",
"D413",
"D415",
"D416",
"S101", # Use of assert detected (OK in test suite)
"S105", # Use of hardcoded password (spurious)
"S106", # Use of hardcoded password (spurious)
"S113", # Probable use of requests call without timeout **fix**
]

# pydocstyle ignore reasons
# -------------------------
# D100: Missing docstring in public module **fix**
# D102: Missing docstring in public method **fix**
# D103: Missing docstring in public function **fix**
# D104: Missing docstring in public package **fix**
# D200: One-line docstring should fit on one line with quotes (optional style)
# D203: 1 blank line required before class docstring (optional style)
# D205: 1 blank line required between summary line and description (optional style)
# D212: Multi-line docstring summary should start at the first line (optional style)
# D400: First line should end with a period (not always a first line)
# D413: Missing blank line after last section ('Parameters')
# D415: First line should end with a period, question mark, or exclamation point (not always a first line)
# D416: Section name should end with a colon ('Warnings:', not 'Warnings') (incorrect?)

# Allow autofix for all enabled rules (when `--fix`) is provided
fixable = ["A", "B", "C", "D", "E", "F"]
Expand Down
2 changes: 1 addition & 1 deletion tests/integration_tests/adapters/betfair/test_kit.py
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ def betting_instrument(
@staticmethod
def market_ids():
"""
A list of market_ids used by the tests. Used in `navigation_short` and `market_catalogue_short`.
Return a list of market_ids used by the tests. Used in `navigation_short` and `market_catalogue_short`.
"""
return (
"1.148894697",
Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/serialization/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def _make_order_events(order, **kwargs):


def nautilus_objects() -> list[Any]:
"""A list of nautilus instances for testing serialization"""
"""Return a list of nautilus instances for testing serialization"""
instrument = TestInstrumentProvider.default_fx_ccy("AUD/USD")
position_id = PositionId("P-001")
buy = TestExecStubs.limit_order()
Expand Down

0 comments on commit af3a720

Please sign in to comment.