Skip to content

Commit

Permalink
feat(sdk): apply ruff format and linting like done in API project
Browse files Browse the repository at this point in the history
  • Loading branch information
maocorte committed Jun 21, 2024
1 parent d73ac2b commit 1c0e32a
Show file tree
Hide file tree
Showing 26 changed files with 875 additions and 761 deletions.
151 changes: 151 additions & 0 deletions sdk/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,154 @@ moto = {extras = ["s3"], version = "^5.0.7"}
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.ruff]
exclude = [".venv", "alembic"]
required-version = ">=0.3.5"
# change the default line length number or characters.
line-length = 88

[tool.ruff.format]
exclude = [".venv", "**/__init__.py"]
quote-style = "single"
indent-style = "space"
docstring-code-format = true

[tool.ruff.lint]
select = [
"B002", # Python does not support the unary prefix increment
"B005", # Using .strip() with multi-character strings is misleading
"B007", # Loop control variable {name} not used within loop body
"B014", # Exception handler with duplicate exception
"B015", # Pointless comparison. Did you mean to assign a value? Otherwise, prepend assert or remove it.
"B018", # Found useless attribute access. Either assign it to a variable or remove it.
"B023", # Function definition does not bind loop variable {name}
"B026", # Star-arg unpacking after a keyword argument is strongly discouraged
"B032", # Possible unintentional type annotation (using :). Did you mean to assign (using =)?
"B904", # Use raise from to specify exception cause
"C", # complexity
"COM818", # Trailing comma on bare tuple prohibited
"D", # docstrings
"DTZ003", # Use datetime.now(tz=) instead of datetime.utcnow()
"DTZ004", # Use datetime.fromtimestamp(ts, tz=) instead of datetime.utcfromtimestamp(ts)
"E", # pycodestyle
"F", # pyflakes/autoflake
"G", # flake8-logging-format
"I", # isort
"ISC", # flake8-implicit-str-concat
"ICN001", # import concentions; {name} should be imported as {asname}
"LOG", # flake8-logging
"N804", # First argument of a class method should be named cls
"N805", # First argument of a method should be named self
"N815", # Variable {name} in class scope should not be mixedCase
"PERF", # Perflint
"PGH004", # Use specific rule codes when using noqa
"PIE", # flake8-pie
"PL", # pylint
"PT", # flake8-pytest-style
"RET", # flake8-return
"RSE", # flake8-raise
"RUF005", # Consider iterable unpacking instead of concatenation
"RUF006", # Store a reference to the return value of asyncio.create_task
# "RUF100", # Unused `noqa` directive; temporarily every now and then to clean them up
"S102", # Use of exec detected
"S103", # bad-file-permissions
"S108", # hardcoded-temp-file
"S306", # suspicious-mktemp-usage
"S307", # suspicious-eval-usage
"S313", # suspicious-xmlc-element-tree-usage
"S314", # suspicious-xml-element-tree-usage
"S315", # suspicious-xml-expat-reader-usage
"S316", # suspicious-xml-expat-builder-usage
"S317", # suspicious-xml-sax-usage
"S318", # suspicious-xml-mini-dom-usage
"S319", # suspicious-xml-pull-dom-usage
"S320", # suspicious-xmle-tree-usage
"S601", # paramiko-call
"S602", # subprocess-popen-with-shell-equals-true
"S604", # call-with-shell-equals-true
"S608", # hardcoded-sql-expression
"S609", # unix-command-wildcard-injection
"SIM", # flake8-simplify
"T100", # Trace found: {name} used
"T20", # flake8-print
"TID251", # Banned imports
"TRY", # tryceratops
"UP", # pyupgrade
"W", # pycodestyle
]

ignore = [
"D100", # Missing docstring in public module
"D101", # Missing docstring in public class
"D102", # Missing docstring in public method
"D103", # Missing docstring in public function
"D104", # Missing docstring in public package
"D107", # Missing docstring in `__init__`
"D202", # No blank lines allowed after function docstring
"D203", # 1 blank line required before class docstring
"D205", # 1 blank line required between summary line and description
"D213", # Multi-line docstring summary should start at the second line
"D400", # First line should end with a period
"D406", # Section name should end with a newline
"D407", # Section name underlining
"D415", # First line should end with a period, question mark, or exclamation point
"E501", # line too long
"E731", # do not assign a lambda expression, use a def
"PLC1901", # {existing} can be simplified to {replacement} as an empty string is falsey; too many false positives
"PLR0911", # Too many return statements ({returns} > {max_returns})
"PLR0912", # Too many branches ({branches} > {max_branches})
"PLR0913", # Too many arguments to function call ({c_args} > {max_args})
"PLR0915", # Too many statements ({statements} > {max_statements})
"PLR2004", # Magic value used in comparison, consider replacing {value} with a constant variable
"PLW2901", # Outer {outer_kind} variable {name} overwritten by inner {inner_kind} target
"PT004", # Fixture {fixture} does not return anything, add leading underscore
"PT011", # pytest.raises({exception}) is too broad, set the `match` parameter or use a more specific exception
"PT012", # `pytest.raises()` block should contain a single simple statement
"PT018", # Assertion should be broken down into multiple parts
"SIM102", # Use a single if statement instead of nested if statements
"SIM108", # Use ternary operator {contents} instead of if-else-block
"SIM115", # Use context handler for opening files
"TRY003", # Avoid specifying long messages outside the exception class
"TRY400", # Use `logging.exception` instead of `logging.error`
"UP006", # keep type annotation style as is
"UP007", # keep type annotation style as is
# Ignored due to performance: https://github.com/charliermarsh/ruff/issues/2923
"UP038", # Use `X | Y` in `isinstance` call instead of `(X, Y)`
# Ignored due to incompatible with mypy: https://github.com/python/mypy/issues/15238
"UP040", # Checks for use of TypeAlias annotation for declaring type aliases.

# May conflict with the formatter, https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules
"W191",
"E111",
"E114",
"E117",
"D206",
"D300",
"Q",
"COM812",
"COM819",
"ISC001",

# Disabled because ruff does not understand type of __all__ generated by a function
"PLE0605"
]

[tool.ruff.lint.extend-per-file-ignores]
"__init__.py" = ["I001"]

[tool.ruff.lint.flake8-pytest-style]
fixture-parentheses = false
mark-parentheses = false

[tool.ruff.lint.flake8-tidy-imports.banned-api]
"async_timeout".msg = "use asyncio.timeout instead"
"pytz".msg = "use zoneinfo instead"

[tool.ruff.lint.isort]
force-sort-within-sections = true
combine-as-imports = true
split-on-trailing-comma = false

[tool.ruff.lint.mccabe]
max-complexity = 25
2 changes: 1 addition & 1 deletion sdk/radicalbit_platform_sdk/apis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
from .model_reference_dataset import ModelReferenceDataset
from .model import Model

__all__ = ["Model", "ModelCurrentDataset", "ModelReferenceDataset"]
__all__ = ['Model', 'ModelCurrentDataset', 'ModelReferenceDataset']
Loading

0 comments on commit 1c0e32a

Please sign in to comment.