diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a20e3170..a84937ba 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,27 +4,20 @@ default_language_version: # force all unspecified python hooks to run python3 python: python3 repos: - - repo: https://github.com/psf/black - rev: 24.3.0 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.6.1 hooks: - - id: black + # Run the linter. + - id: ruff + args: + - --fix + # Run the formatter. + - id: ruff-format - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: v4.6.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer - id: check-json - id: pretty-format-json args: [--autofix, --no-ensure-ascii, --indent=4] - - repo: https://github.com/pycqa/flake8 - rev: 7.0.0 - hooks: - - id: flake8 - args: [--max-line-length=120, "--ignore=E203,W503"] - additional_dependencies: [flake8-bugbear] - - repo: https://github.com/pycqa/isort - rev: 5.13.2 - hooks: - - id: isort - name: isort (python) - args: ["--profile", "black", "--filter-files"] diff --git a/dev-requirements.txt b/dev-requirements.txt index e4df8f2a..2a09bc85 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -4,11 +4,11 @@ # # pip-compile --extra=dev --no-emit-index-url --output-file=dev-requirements.txt # -backports-tarfile==1.1.1 +backports-tarfile==1.2.0 # via jaraco-context build==1.2.1 # via domdiv (pyproject.toml) -certifi==2024.2.2 +certifi==2024.7.4 # via requests cfgv==3.4.0 # via pre-commit @@ -26,15 +26,15 @@ docutils==0.21.2 # via readme-renderer doit==0.36.0 # via domdiv (pyproject.toml) -exceptiongroup==1.2.1 +exceptiongroup==1.2.2 # via pytest -filelock==3.14.0 +filelock==3.15.4 # via virtualenv -identify==2.5.36 +identify==2.6.0 # via pre-commit idna==3.7 # via requests -importlib-metadata==7.1.0 +importlib-metadata==8.2.0 # via # build # doit @@ -46,9 +46,9 @@ jaraco-classes==3.4.0 # via keyring jaraco-context==5.3.0 # via keyring -jaraco-functools==4.0.1 +jaraco-functools==4.0.2 # via keyring -keyring==25.2.0 +keyring==25.3.0 # via twine loguru==0.7.2 # via domdiv (pyproject.toml) @@ -56,45 +56,45 @@ markdown-it-py==3.0.0 # via rich mdurl==0.1.2 # via markdown-it-py -more-itertools==10.2.0 +more-itertools==10.4.0 # via # jaraco-classes # jaraco-functools -nh3==0.2.17 +nh3==0.2.18 # via readme-renderer -nodeenv==1.8.0 +nodeenv==1.9.1 # via pre-commit -packaging==24.0 +packaging==24.1 # via # build # pytest -pillow==10.3.0 +pillow==10.4.0 # via # domdiv (pyproject.toml) # reportlab pkginfo==1.10.0 # via twine -platformdirs==4.2.1 +platformdirs==4.2.2 # via virtualenv pluggy==1.5.0 # via pytest -pre-commit==3.7.0 +pre-commit==3.8.0 # via domdiv (pyproject.toml) -pygments==2.17.2 +pygments==2.18.0 # via # readme-renderer # rich pyproject-hooks==1.1.0 # via build -pytest==8.2.0 +pytest==8.3.2 # via domdiv (pyproject.toml) -pyyaml==6.0.1 +pyyaml==6.0.2 # via pre-commit -readme-renderer==43.0 +readme-renderer==44.0 # via twine -reportlab==4.2.0 +reportlab==4.2.2 # via domdiv (pyproject.toml) -requests==2.31.0 +requests==2.32.3 # via # requests-toolbelt # twine @@ -108,16 +108,13 @@ tomli==2.0.1 # via # build # pytest -twine==5.0.0 +twine==5.1.1 # via domdiv (pyproject.toml) -urllib3==2.2.1 +urllib3==2.2.2 # via # requests # twine -virtualenv==20.26.1 +virtualenv==20.26.3 # via pre-commit -zipp==3.18.1 +zipp==3.20.0 # via importlib-metadata - -# The following packages are considered to be unsafe in a requirements file: -# setuptools diff --git a/pyproject.toml b/pyproject.toml index 5cd6e009..9c3fc1c2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,3 +31,6 @@ domdiv_dedupe_cards = "domdiv.tools.cleanup_language_dupes:main" [tool.setuptools_scm] # doing this break CI as the version file gets written when just `get_version` is called # version_file = "src/domdiv/_version.py" + +[tool.ruff.lint] +select = ["I"] diff --git a/requirements.txt b/requirements.txt index c57be7f4..0ecad9a9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,9 +10,9 @@ configargparse==1.7 # via domdiv (pyproject.toml) loguru==0.7.2 # via domdiv (pyproject.toml) -pillow==10.3.0 +pillow==10.4.0 # via # domdiv (pyproject.toml) # reportlab -reportlab==4.2.0 +reportlab==4.2.2 # via domdiv (pyproject.toml) diff --git a/src/domdiv/draw.py b/src/domdiv/draw.py index e9e63929..fb2bfff5 100644 --- a/src/domdiv/draw.py +++ b/src/domdiv/draw.py @@ -378,9 +378,7 @@ def __init__(self, canvas, x=0, y=0, cropmarkLength=-1, cropmarkSpacing=-1): self.NO_LINE, self.DOT, self.DEBUG, - ) = range( - 1, 9 - ) # Constants + ) = range(1, 9) # Constants if cropmarkLength < 0: cropmarkLength = 0.2 if cropmarkSpacing < 0: @@ -852,7 +850,9 @@ def drawPanelOutline( line = ( plotter.LINE if lineType.lower() == "line" - else plotter.DOT if lineType.lower() == "dot" else NO_LINE + else plotter.DOT + if lineType.lower() == "dot" + else NO_LINE ) # lines ending at a midpoint (no dots) midline = NO_LINE if line == plotter.DOT else line @@ -1076,7 +1076,9 @@ def tabHeight(panelStyle, panelHeight): return ( panelHeight if panelStyle in ["tab", "strap"] - else item.tabHeight if panelStyle == "folder" else 0.0 + else item.tabHeight + if panelStyle == "folder" + else 0.0 ) headTabHeight = tabHeight(self.options.head, headHeight) diff --git a/src/domdiv/main.py b/src/domdiv/main.py index 9a10a150..f8dbb9c6 100644 --- a/src/domdiv/main.py +++ b/src/domdiv/main.py @@ -124,9 +124,7 @@ def by_cost_sort_key(self, card): ) def get_card_name_sort_key(self, c): - if ( - self.collator - ): # If the PyICU collator attribute has been set up, get the collator based sort key + if self.collator: # If the PyICU collator attribute has been set up, get the collator based sort key return self.collator.getSortKey(c) else: # Default method: strip the card name character accents return self.strip_accents(c) @@ -338,21 +336,21 @@ def filter_sort_cards(cards, options): if card.group_top: # this is a designated card to represent the group, so update important data group_cards[(card.group_tag, card.cardset_tag)].cost = card.cost - group_cards[(card.group_tag, card.cardset_tag)].potcost = ( - card.potcost - ) - group_cards[(card.group_tag, card.cardset_tag)].debtcost = ( - card.debtcost - ) - group_cards[(card.group_tag, card.cardset_tag)].types = ( - card.types - ) - group_cards[(card.group_tag, card.cardset_tag)].randomizer = ( - card.randomizer - ) - group_cards[(card.group_tag, card.cardset_tag)].image = ( - card.image - ) + group_cards[ + (card.group_tag, card.cardset_tag) + ].potcost = card.potcost + group_cards[ + (card.group_tag, card.cardset_tag) + ].debtcost = card.debtcost + group_cards[ + (card.group_tag, card.cardset_tag) + ].types = card.types + group_cards[ + (card.group_tag, card.cardset_tag) + ].randomizer = card.randomizer + group_cards[ + (card.group_tag, card.cardset_tag) + ].image = card.image group_cards[(card.group_tag, card.cardset_tag)].addCardCount( card.count @@ -394,9 +392,7 @@ def filter_sort_cards(cards, options): # Split out Official and Fan set information Official_sets = set() # Will hold official sets - Official_search = ( - [] - ) # Will hold official sets for searching, both set key and set_name + Official_search = [] # Will hold official sets for searching, both set key and set_name Fan_sets = set() # Will hold fan sets Fan_search = [] # Will hold fan sets for searching, both set key and set_name wantedSets = set() # Will hold all the sets requested for printing