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
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ jobs:
strategy:
matrix:
include:
- dependencies: black python3-isort
- dependencies: ruff
task: make -f Makefile fmt-travis
- dependencies: yamllint
task: make -f Makefile yamllint
- dependencies: >
pylint
python3-hypothesis
python3-justbases
python3-setuptools
task: PYTHONPATH=./src make -f Makefile lint
ruff
task: make -f Makefile lint
- dependencies: >
python3-hypothesis
python3-justbases
Expand Down
17 changes: 0 additions & 17 deletions .isort.cfg

This file was deleted.

12 changes: 5 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
.PHONY: lint
lint:
pylint setup.py
pylint src/justbytes
pylint tests --disable=unnecessary-dunder-call
ruff check

.PHONY: test
test:
Expand All @@ -16,13 +14,13 @@ coverage:

.PHONY: fmt
fmt:
isort setup.py src tests --skip src/justbytes/__init__.py
black .
ruff check --fix --select I
ruff format

.PHONY: fmt-travis
fmt-travis:
isort --diff --check-only setup.py src tests --skip src/justbytes/__init__.py
black . --check
ruff check --select I
ruff format --check

PYREVERSE_OPTS = --output=pdf
.PHONY: view
Expand Down
7 changes: 4 additions & 3 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import sys, os
import os
import sys

import justbytes

Expand Down Expand Up @@ -188,7 +189,7 @@
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
("index", "justbytes.tex", "justbytes Documentation", "mulhern", "manual"),
("index", "justbytes.tex", "justbytes Documentation", "mulhern", "manual")
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down Expand Up @@ -236,7 +237,7 @@
"justbytes",
"One line description of project.",
"Miscellaneous",
),
)
]

# Documents to append as an appendix to all manuals.
Expand Down
14 changes: 14 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[tool.ruff]
target-version = "py312"
line-length = 88

[tool.ruff.lint]
select = ["PL"]

[tool.ruff.lint.isort]
known-first-party = ["justbases"]
split-on-trailing-comma = false

[tool.ruff.format]
skip-magic-trailing-comma = true
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
Python packaging file for setup tools.
"""

# isort: THIRDPARTY
import setuptools

setuptools.setup()
15 changes: 3 additions & 12 deletions src/justbytes/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

# pylint: disable=invalid-name

# isort: FIRSTPARTY
import justbases

from ._constants import PRECISE_NUMERIC_TYPES, UNITS, RoundingMethods
Expand All @@ -33,8 +32,6 @@ class BaseConfig(justbases.BaseConfig):
Override defaults of justbases.BaseConfig.
"""

# pylint: disable=too-few-public-methods

def __init__(self, use_prefix=False, use_subscript=False):
"""
Initializer.
Expand All @@ -55,8 +52,6 @@ class DisplayConfig(justbases.DisplayConfig):
DisplayConfig overrides justbases.DisplayConfig's defaults.
"""

# pylint: disable=too-few-public-methods

def __init__(
self,
show_approx_str=True,
Expand Down Expand Up @@ -97,8 +92,6 @@ class ValueConfig:
but 0.05 GiB is still displayed as 51.2 MiB.
"""

# pylint: disable=too-few-public-methods

_FMT_STR = ", ".join(
[
"base=%(base)s",
Expand All @@ -111,7 +104,7 @@ class ValueConfig:
]
)

def __init__( # pylint: disable=too-many-positional-arguments
def __init__( # noqa: PLR0913
self,
max_places=2,
min_value=1,
Expand All @@ -134,7 +127,7 @@ def __init__( # pylint: disable=too-many-positional-arguments
:param base: numeric base
:param rounding_method: one of RoundingMethods.METHODS()
"""
# pylint: disable=too-many-arguments

if max_places is not None and max_places < 0:
raise RangeValueError(max_places, "max_places", "must be an int at least 0")

Expand All @@ -148,7 +141,7 @@ def __init__( # pylint: disable=too-many-positional-arguments
unit, "unit", f"must be one of {', '.join(str(x) for x in UNITS())}"
)

if base < 2:
if base < 2: # noqa: PLR2004
raise RangeValueError(base, "base", "must be at least 2")

self.max_places = max_places
Expand Down Expand Up @@ -177,8 +170,6 @@ def __str__(self):
class StringConfig:
"""Configuration for :class:`Range` class."""

# pylint: disable=too-few-public-methods

def __init__(self, value_config, display_config, display_impl):
"""
Initializer.
Expand Down
18 changes: 3 additions & 15 deletions src/justbytes/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@
* Size units, e.g., Ki, Mi
"""

# isort: STDLIB
import abc
from numbers import Rational

# isort: FIRSTPARTY
import justbases

from ._errors import RangeValueError
Expand All @@ -37,8 +35,6 @@
class Unit:
"""Class to encapsulate unit information."""

# pylint: disable=too-few-public-methods

def __init__(self, factor, prefix, abbr):
self._factor = factor
self._prefix = prefix
Expand All @@ -49,7 +45,6 @@ def __str__(self):

__repr__ = __str__

# pylint: disable=protected-access
factor = property(lambda s: s._factor, doc="numeric multiple of bytes")
abbr = property(lambda s: s._abbr, doc="abbreviation for unit, precedes 'B'")
prefix = property(lambda s: s._prefix, doc="prefix for 'bytes'")
Expand All @@ -67,23 +62,21 @@ class Units(metaclass=abc.ABCMeta):
Generic class for units.
"""

# pylint: disable=too-few-public-methods

FACTOR = abc.abstractproperty(doc="factor for each unit")

_UNITS = abc.abstractproperty(doc="ordered list of units")

_MAX_EXPONENT = None

@classmethod
def UNITS(cls): # pylint: disable=invalid-name
def UNITS(cls):
"""
Units of this class.
"""
return cls._UNITS[:]

@classmethod
def unit_for_exp(cls, exponent): # pylint: disable=invalid-name
def unit_for_exp(cls, exponent):
"""
Get the unit for the given exponent.

Expand Down Expand Up @@ -112,9 +105,6 @@ def max_exponent(cls):
class DecimalUnits(Units):
"""Class to store decimal unit constants."""

# pylint: disable=invalid-name
# pylint: disable=too-few-public-methods

FACTOR = 10**3

KB = Unit(FACTOR**1, "kilo", "k")
Expand All @@ -132,8 +122,6 @@ class DecimalUnits(Units):
class BinaryUnits(Units):
"""Class to store binary unit constants."""

# pylint: disable=too-few-public-methods

FACTOR = 2**10

KiB = Unit(FACTOR**1, "kibi", "Ki")
Expand All @@ -148,7 +136,7 @@ class BinaryUnits(Units):
_UNITS = [KiB, MiB, GiB, TiB, PiB, EiB, ZiB, YiB]


def UNITS(): # pylint: disable=invalid-name
def UNITS():
"""All unit constants."""
return [B] + BinaryUnits.UNITS() + DecimalUnits.UNITS()

Expand Down
7 changes: 3 additions & 4 deletions src/justbytes/_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

"""Exception types used by the justbytes class."""

# isort: STDLIB
import abc


Expand All @@ -42,7 +41,7 @@ def __init__(self, value, param, msg=None):
:param str param: the parameter
:param str msg: an explanatory message
"""
# pylint: disable=super-init-not-called

self.value = value
self.param = param
self.msg = msg
Expand Down Expand Up @@ -74,7 +73,7 @@ def __init__(self, operator, other):
:param str operator: the operator
:param object other: the other argument
"""
# pylint: disable=super-init-not-called

self._operator = operator
self._other = other

Expand All @@ -94,7 +93,7 @@ def __init__(self, operator, other):
:param str operator: the operator
:param object other: the other argument
"""
# pylint: disable=super-init-not-called

self._operator = operator
self._other = other

Expand Down
2 changes: 1 addition & 1 deletion src/justbytes/_generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ def next_or_last(pred, seq, default=None):
if pred(elem):
return elem
try:
return elem # pylint: disable=undefined-loop-variable
return elem
except NameError:
return default
Loading