Skip to content

Commit

Permalink
ci: try preview version of ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleKing committed Nov 6, 2023
1 parent 5c209c4 commit bf4ba53
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 16 deletions.
2 changes: 2 additions & 0 deletions .ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ ignore = [
'ANN102', # Missing type annotation for `cls` in classmethod
'ANN401', # Dynamically typed expressions (typing.Any) are disallowed in `**kwargs`
'BLE001', # Do not catch blind exception: `Exception`
'CPY001', # Missing copyright notice at top of file
'D203', # "1 blank line required before class docstring" (Conflicts with D211)
'D213', # "Multi-line docstring summary should start at the second line" (Conflicts with D212)
'D4', # Numpy-Style Docstrings (e.g. "Section name should end with a newline ("Returns")")
Expand All @@ -33,6 +34,7 @@ ignore = [
'TRY003', # Avoid specifying long messages outside the exception class
]
line-length = 120
preview = true
select = ['ALL']
target-version = 'py39'
unfixable = [
Expand Down
2 changes: 1 addition & 1 deletion calcipy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def configure_runtime_type_checking_mode() -> None: # pragma: no cover
rtc_mode = _RuntimeTypeCheckingModes.from_environment()

if rtc_mode is not _RuntimeTypeCheckingModes.OFF:
from beartype.roar import BeartypeClawDecorWarning
from beartype.roar import BeartypeClawDecorWarning # noqa: PLC0415

beartype_this_package(conf=BeartypeConf(
warning_cls_on_decorator_exception=(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class _HostedPythonPackage(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True)

@field_serializer('datetime', 'latest_datetime')
def serialize_datetime(self, value: Optional[Arrow]) -> Optional[str]:
def serialize_datetime(self, value: Optional[Arrow]) -> Optional[str]: # noqa: PLR6301
return str(value) if value else None

@field_validator('datetime', 'latest_datetime', mode='before')
Expand Down
10 changes: 5 additions & 5 deletions calcipy/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ def print_help(self) -> None: # pragma: no cover
"""
super().print_help()
print('Global Task Options:') # noqa: T201
print('') # noqa: T201
print() # noqa: T201
self.print_columns([
('*file_args', 'List of Paths available globally to all tasks. Will resolve paths with working_dir'),
('--keep-going', 'Continue running tasks even on failure'),
('--working_dir=STRING', 'Set the cwd for the program. Example: "../run --working-dir .. lint test"'),
('-v,-vv,-vvv', 'Globally configure logger verbosity (-vvv for most verbose)'),
])
print('') # noqa: T201
print() # noqa: T201


class CalcipyConfig(Config):
Expand Down Expand Up @@ -80,9 +80,9 @@ def start_program( # noqa: CAC001
elif argv == '--keep-going':
_gto.keep_going = True
# Check for CLI arguments with values
elif last_argv in {'--working-dir'}:
elif last_argv == '--working-dir':
_gto.working_dir = Path(argv).resolve()
elif argv not in {'--working-dir'}:
elif argv != '--working-dir':
sys_argv.append(argv)
last_argv = argv
_gto.file_args = [
Expand Down Expand Up @@ -121,7 +121,7 @@ def _with_kwargs(**extra_kwargs: Any) -> Callable: # type: ignore[type-arg] # n
# Set a unique name when 'extra_kwargs' was provided
# https://github.com/pyinvoke/invoke/blob/07b836f2663bb073a7bcef3d6c454e1dc6b867ae/invoke/tasks.py#L81-L104
encoded = b64encode(str(extra_kwargs).encode())
func.__name__ = f'{func.__name__}_{encoded.decode().rstrip("=")}'
func.__name__ = f'{func.__name__}_{encoded.decode().rstrip('=')}'

@wraps(func) # nosem
def _with_kwargs_inner(*args: Any, **kwargs: Any) -> Any:
Expand Down
16 changes: 8 additions & 8 deletions calcipy/scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@

def start() -> None: # pragma: no cover
"""Run the customized Invoke Program."""
from .tasks import all_tasks
from .tasks import all_tasks # noqa: PLC0415
start_program(__pkg_name__, __version__, all_tasks)


def _start_subset(modules: List[ModuleType]) -> None: # pragma: no cover
"""Run the specified subset."""
from .tasks.defaults import new_collection
from .tasks.defaults import new_collection # noqa: PLC0415

ns = new_collection()
for module in modules:
Expand All @@ -28,35 +28,35 @@ def _start_subset(modules: List[ModuleType]) -> None: # pragma: no cover

def start_docs() -> None: # pragma: no cover
"""Run CLI with only the cl and doc namespaces."""
from .tasks import cl, doc
from .tasks import cl, doc # noqa: PLC0415
_start_subset([cl, doc])


def start_lint() -> None: # pragma: no cover
"""Run CLI with only the lint namespace."""
from .tasks import lint
from .tasks import lint # noqa: PLC0415
_start_subset([lint])


def start_pack() -> None: # pragma: no cover
"""Run CLI with only the pack namespace."""
from .tasks import pack
from .tasks import pack # noqa: PLC0415
_start_subset([pack])


def start_tags() -> None: # pragma: no cover
"""Run CLI with only the tags namespace."""
from .tasks import tags
from .tasks import tags # noqa: PLC0415
_start_subset([tags])


def start_test() -> None: # pragma: no cover
"""Run CLI with only the test namespace."""
from .tasks import test
from .tasks import test # noqa: PLC0415
_start_subset([test])


def start_types() -> None: # pragma: no cover
"""Run CLI with only the types namespace."""
from .tasks import types
from .tasks import types # noqa: PLC0415
_start_subset([types])
2 changes: 1 addition & 1 deletion calcipy/tasks/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def coverage(ctx: Context, *, min_cover: int = 0, out_dir: Optional[str] = None,

cov_dir = Path(out_dir or from_ctx(ctx, 'test', 'out_dir'))
cov_dir.mkdir(exist_ok=True, parents=True)
print('') # noqa: T201
print() # noqa: T201
for cli_args in (
'report --show-missing', # Write to STDOUT
f'html --directory={cov_dir}', # Write to HTML
Expand Down

0 comments on commit bf4ba53

Please sign in to comment.