Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ jobs:
- name: Run pylint
run: poetry run task pylint

- name: Run ruff
run: poetry run task ruff

- name: Run pytest
run: poetry run task test
env:
Expand Down
1 change: 1 addition & 0 deletions lib/binarylane/types.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
""" Contains some shared types for properties """

from __future__ import annotations

from http import HTTPStatus
Expand Down
1,121 changes: 609 additions & 512 deletions poetry.lock

Large diffs are not rendered by default.

17 changes: 15 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ types-python-dateutil = "^2.8.19"
pytest = "^7.2.0"
absolufy-imports = "^0.3.1"
binarylane-python-client = "^0.13.2a0"
safety = "*"
safety = "<3.0.0"
ruff = "^0.9.6"

[tool.poetry.group.pylint.dependencies]
pylint = { version = "^3.3.4", python = ">=3.9" }
Expand All @@ -38,10 +39,11 @@ generate = "python scripts/generate.py"
black = "black ."
isort = "isort ."
mypy = "mypy ."
ruff = "ruff check src"
pylint = "pylint src"
safety = "poetry export -f requirements.txt | safety check --bare --stdin"
test = "pytest tests"
check = "task isort && task black && task mypy && task pylint && task test && task safety"
check = "task isort && task black && task mypy && task ruff && task pylint && task test && task safety"

[tool.isort]
py_version = 37
Expand All @@ -58,6 +60,17 @@ add_imports=["from __future__ import annotations"]
line-length = 120
target_version = ["py37"]

[tool.ruff]
# Always generate Python 3.8-compatible code.
target-version = "py38"
line-length = 120
exclude = [
"api", # generated command classes
]

[tool.ruff.lint]
select = ["E4", "E7", "E9", "F", "TC"]

[tool.pylint.format]
max-line-length = 120
ignore-paths = ['src/binarylane/console/commands/*/']
Expand Down
1 change: 1 addition & 0 deletions scripts/generate.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Generate updated API bindings and CLI commands from OpenAPI specification document"""

from __future__ import annotations

import re
Expand Down
9 changes: 3 additions & 6 deletions src/binarylane/config/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,13 @@ class OptionAttributes(ABC):
UNCONFIGURED_TOKEN: ClassVar[str] = "unconfigured"

@abstractmethod
def get_option(self, name: OptionName) -> Optional[str]:
...
def get_option(self, name: OptionName) -> Optional[str]: ...

@abstractmethod
def required_option(self, name: OptionName) -> str:
...
def required_option(self, name: OptionName) -> str: ...

@abstractmethod
def add_option(self, name: OptionName, value: str) -> None:
...
def add_option(self, name: OptionName, value: str) -> None: ...

@staticmethod
def to_bool(name: str) -> bool:
Expand Down
3 changes: 1 addition & 2 deletions src/binarylane/config/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@


class Source(Protocol):
def get(self, name: str) -> Optional[str]:
...
def get(self, name: str) -> Optional[str]: ...


T = TypeVar("T", bound=Source)
Expand Down
6 changes: 4 additions & 2 deletions src/binarylane/config/sources.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
from __future__ import annotations

import argparse
import configparser
import os
import sys
from abc import ABC
from pathlib import Path
from typing import ClassVar, Dict, Optional
from typing import TYPE_CHECKING, ClassVar, Dict, Optional

if TYPE_CHECKING:
import argparse


class _SourceBase(ABC):
Expand Down
1 change: 1 addition & 0 deletions src/binarylane/console/commands/api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
""" Contains methods for accessing the API """

from __future__ import annotations

import re
Expand Down
9 changes: 4 additions & 5 deletions src/binarylane/console/parser/attribute.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
from __future__ import annotations

import argparse
import logging
from abc import ABC, abstractmethod
from typing import TYPE_CHECKING, ClassVar, List, Optional

logger = logging.getLogger(__name__)

if TYPE_CHECKING:
import argparse

from binarylane.console.parser.object_attribute import ObjectAttribute
from binarylane.console.parser.parser import Parser

Expand Down Expand Up @@ -62,12 +63,10 @@ def group_name(self) -> Optional[str]:
return self.parent.group_name if self.parent else None

@abstractmethod
def configure(self, parser: Parser) -> None:
...
def configure(self, parser: Parser) -> None: ...

@abstractmethod
def construct(self, parser: Parser, parsed: argparse.Namespace) -> object:
...
def construct(self, parser: Parser, parsed: argparse.Namespace) -> object: ...

def _unsupported(self, message: str, error: bool = True) -> None:
"""Report that command parsing is not likely to work correctly"""
Expand Down
6 changes: 3 additions & 3 deletions src/binarylane/console/parser/list_attribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ def configure(self, parser: Parser) -> None:
parser.add_group_help(title=self.title, description=self.description, entries=usage_descriptions)

parser.add_keyword(self.keyword)
parser.add_argument(
self.attribute_name, type=str, nargs=argparse.PARSER, help=argparse.SUPPRESS
).required = False
parser.add_argument(self.attribute_name, type=str, nargs=argparse.PARSER, help=argparse.SUPPRESS).required = (
False
)

def _create_singlestore_action(self, **kwargs: Any) -> argparse.Action:
action = SingleStoreAction(**kwargs)
Expand Down
3 changes: 2 additions & 1 deletion src/binarylane/console/parser/object_attribute.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations

import argparse
import logging
from typing import TYPE_CHECKING, List, Optional, TypeVar

Expand All @@ -9,6 +8,8 @@
from binarylane.console.parser.attribute import Attribute

if TYPE_CHECKING:
import argparse

from binarylane.console.parser.parser import Parser

logger = logging.getLogger(__name__)
Expand Down
3 changes: 1 addition & 2 deletions src/binarylane/console/parser/primitive_attribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ def is_primitive_type(type_: type) -> bool:
class Lookup(typing.Protocol):
"""Lookup is a function that accepts an entity reference (e.g. its name) and returns that entity's ID"""

def __call__(self, ref: str) -> Optional[int]:
...
def __call__(self, ref: str) -> Optional[int]: ...


class PrimitiveAttribute(Attribute):
Expand Down
1 change: 1 addition & 0 deletions src/binarylane/console/printers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Printers provide different methods of formatting and displaying API responses"""

from __future__ import annotations

from enum import Enum
Expand Down
1 change: 1 addition & 0 deletions src/binarylane/pycompat/actions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
""" BooleanOptionalAction imported from 3.9 """

from __future__ import annotations

import argparse
Expand Down
Loading