Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
63b53eb
Continue work on docs
Eutropios Sep 10, 2025
add0c9d
Continue trying to figure out github actions
Eutropios Sep 11, 2025
5b7b309
Lets see if this finishes it
Eutropios Sep 11, 2025
e6bc156
Attempting to fix action
Eutropios Sep 11, 2025
0c5eeff
Let's see if that fixes the 3.11 error
Eutropios Sep 12, 2025
284c4ba
Lets see if this fixes the iso issue
Eutropios Sep 12, 2025
e57ab03
Lets hope this finally fixes the 3.10 errors
Eutropios Sep 12, 2025
aeb8c08
Removing extra GHA check
Eutropios Sep 12, 2025
b64d233
I wish Python 3.10 had proper ISO 8601 support
Eutropios Sep 12, 2025
e234467
Lets see if pulling in this dependency is better
Eutropios Sep 12, 2025
b4c9cab
Fixing the lock
Eutropios Sep 12, 2025
fdccd25
Fix regex match
Eutropios Sep 12, 2025
ea70323
Can we please be done with this? I'm busy
Eutropios Sep 12, 2025
d51193a
Drop 3.9 support bc I refuse to adjust my code
Eutropios Sep 15, 2025
8dbbfda
Fix lock
Eutropios Sep 15, 2025
db2a065
Fix lock (for real this time)
Eutropios Sep 15, 2025
f4b1875
Test er out
Eutropios Sep 15, 2025
5f2622a
Lets give er a shot
Eutropios Sep 15, 2025
7e5d530
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 15, 2025
a5cc1c0
Lets see if this works
Eutropios Sep 15, 2025
874d983
Merge branch 'development' of https://github.com/Eutropios/WarMAC int…
Eutropios Sep 15, 2025
34c0192
We keep testing, broski
Eutropios Sep 15, 2025
5fd28c8
Interestin
Eutropios Sep 15, 2025
6da0255
Test
Eutropios Sep 15, 2025
e8e4fc7
Give er a shot
Eutropios Sep 15, 2025
607660f
Rebuild lock
Eutropios Sep 15, 2025
a8a775c
Add markdownlint
Eutropios Sep 15, 2025
decb538
Fix mypy ci check
Eutropios Sep 29, 2025
3569fc4
Update pre-commit config
Eutropios Sep 29, 2025
776c772
Make CI more concise
Eutropios Sep 29, 2025
8662a21
Testing this hook
Eutropios Sep 29, 2025
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
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ trim_trailing_whitespace = true
; trailing whitespace is relevant in these languages
trim_trailing_whitespace = false

[*.{md,yaml,toml}]
[*.{md,toml,yaml,yml}]
indent_size = 2

[*.rst]
Expand Down
60 changes: 60 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Lint and Format

on: [pull_request, workflow_dispatch]

jobs:
lint:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: markdownlint-cli2-action
uses: DavidAnson/markdownlint-cli2-action@v20.0.0
with:
config: ".markdownlint.yaml"
globs: "**/*.md"

- name: "Set up Python"
uses: actions/setup-python@v5
with:
python-version-file: "pyproject.toml"

- name: Install uv
uses: astral-sh/setup-uv@v6

- name: Install the project
run: uv sync --locked

- name: Format docstrings
run: uvx docformatter . --black --pre-summary-newline -r -s sphinx --wrap-summaries 72 --wrap-descriptions 72

- name: Ruff lint
run: uvx ruff check . --exit-non-zero-on-fix

- name: Ruff format
run: uvx ruff format . --check

mypy:
name: mypy
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- "3.10"
- "3.11"
- "3.12"
- "3.13"

steps:
- uses: actions/checkout@v4

- name: Install uv and set the python version
uses: astral-sh/setup-uv@v6
with:
python-version: ${{ matrix.python-version }}

- name: Install deps
run: uv sync --no-dev --locked --group typeChecking
- name: Run mypy
run: uv run mypy .
7 changes: 4 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Test

on: [push, pull_request, workflow_dispatch]
on: [pull_request, workflow_dispatch]

jobs:
test:
Expand All @@ -9,7 +9,6 @@ jobs:
strategy:
matrix:
python-version:
- "3.9"
- "3.10"
- "3.11"
- "3.12"
Expand All @@ -23,5 +22,7 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Install deps
run: uv sync --no-dev --locked --group test
- name: Run tests
run: python3 --version
run: uv run pytest tests -vv
5 changes: 3 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ repos:
- --files
- .git/COMMIT_EDITMSG
stages: [commit-msg]
always_run: true # This might not be necessary.

- repo: https://github.com/abravalheri/validate-pyproject
rev: "v0.24.1"
Expand All @@ -31,14 +32,14 @@ repos:
args: [-i, -e ./tests]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.13.0"
rev: "v0.13.2"
hooks:
- id: ruff-check
args: [--exit-non-zero-on-fix]
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.17.1"
rev: "v1.18.2"
hooks:
- id: mypy
args: [--strict, --ignore-missing-imports]
Expand Down
3 changes: 0 additions & 3 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,4 @@ sphinx:
# Optionally build your docs in additional formats such as PDF and ePub
formats:
- pdf
# Optionally build your docs in additional formats such as PDF and ePub
# formats:
# - pdf
# - epub
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ mods, and arcane enhancements.

## Installation<a id="installation"></a> <!--This ensures PyPI compatibility-->

WarMAC only supports Python versions 3.9 to 3.13.
WarMAC only supports Python versions 3.10 to 3.13.

The primary method of installing WarMAC is by installing it through [pipx](https://pypa.github.io/pipx/)
or through [uv](https://docs.astral.sh/uv/guides/tools/).
Expand Down
1 change: 1 addition & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"capsys",
"copybutton",
"crossplay",
"dateutil",
"docformatter",
"endo",
"eutropios",
Expand Down
6 changes: 6 additions & 0 deletions docs/source/cli/average.rst
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,13 @@ Handling Output
$ warmac average -p PC -t 2 -d "vengeful revenant" > warmacOut.txt
$ cat warmacOut.txt
Item: Vengeful Revenant
Time Range: 2 days
Median Price: 5.0 platinum
Max Price: 30 platinum
Min Price: 4 platinum
Number of Orders: 38

Porcelain Output
----------------

| Porcelain output is in the form of colon-separated values.
26 changes: 16 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,28 @@
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: Implementation :: CPython",
"Topic :: Utilities",
"Typing :: Typed",
]

dependencies = ["msgspec>=0.19.0", "urllib3>=2.0.4"]
dependencies = [
"msgspec>=0.19.0",
"python-dateutil>=2.9; python_version < '3.11'",
"urllib3>=2.0.4",
]
# come time to introduce logging, some options are:
# The logging stdlib module, Loguru, structlog, picologging, logbook, Eliot
# Do research on all options to see which is best fit
description = "An average platinum price calculator for tradeable items in Warframe."
# include = [""]

keywords = ["platinum", "warframe calculator", "warframe market", "warframe"]

keywords = ["platinum", "warframe calculator", "warframe market", "warframe"]
license = {text = "GPL-3.0-or-later"}
maintainers = [{name = "Noah Jenner", email = "noah.jenner@proton.me"}]
name = "WarMAC"
readme = "README.md"
requires-python = ">=3.9"
requires-python = ">=3.10"
version = "0.0.5"

[project.scripts]
Expand All @@ -57,7 +59,6 @@
"sphinx-last-updated-by-git>=0.3.6",
"sphinx-lint>=1",
"sphinx-notfound-page>=1",
"sphinx<8.0,>=7.2; python_version < '3.10' and python_version >= '3.9'",
"sphinx<8.2,>=8.0; python_version >= '3.10' and python_version < '3.11'",
"sphinx>=8.2; python_version >= '3.11'",
]
Expand All @@ -67,6 +68,14 @@
"pytest-mock>=3.14",
"pytest>=8.0",
]
typeChecking = [
"msgspec",
"mypy",
"pytest",
"pytest-mock",
"python-dateutil>=2.9; python_version < '3.11'",
"urllib3",
]

[tool.coverage.run]
command_line = "-m pytest -vv ./tests"
Expand All @@ -88,9 +97,6 @@
wrap-descriptions = 72
wrap-summaries = 72

[tool.docstrfmt]
line-length = 80

[tool.mypy]
exclude = ["_build", "buck-out", "build", "dist", "htmlcov"]

Expand All @@ -117,7 +123,7 @@
line-length = 88
preview = true
show-fixes = true
target-version = "py39"
target-version = "py310"

[tool.ruff.format]
indent-style = "space"
Expand Down
25 changes: 22 additions & 3 deletions src/warmac/average.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,24 @@

from __future__ import annotations

import datetime
import sys
from typing import TYPE_CHECKING

from warmac import config, errors, fetch_data, schema

if sys.version_info >= (3, 11):
# NOTE: When Python 3.10 EOL, use datetime instead of dateutil
from datetime import datetime as dt

parse = dt.fromisoformat
else:
import dateutil.parser

parse = dateutil.parser.parse

if TYPE_CHECKING:
import argparse
import datetime
from typing import Literal


Expand Down Expand Up @@ -80,7 +91,15 @@ def in_time_range(
:return: True if ``last_updated ≤ time_range``, False if
``last_updated > time_range``.
"""
timestamp = datetime.datetime.fromisoformat(last_updated)
"""
If sys.version_info >= (3, 11):

# Use just this when 3.10 eol
timestamp = datetime.datetime.fromisoformat(last_updated)
else:
timestamp = dateutil.parser.parse(last_updated)
"""
timestamp = parse(last_updated)
return 0 <= (current_time - timestamp).days <= time_range


Expand Down Expand Up @@ -230,7 +249,7 @@ def format_output(stat: float, plat_list: list[int], args: argparse.Namespace) -
space_after_label = 23
return (
f"{'Item:':{space_after_label}}{item_name}\n"
f"{'Time Range:':{space_after_label}}{args.timerange} days\n"
f"{'Time Range:':{space_after_label}}{args.timerange} day(s)\n"
f"{f'{statistic} Price:':{space_after_label}}{stat} platinum\n"
f"{'Max Price:':{space_after_label}}{max_list:.0f} platinum\n"
f"{'Min Price:':{space_after_label}}{min_list:.0f} platinum\n"
Expand Down
1 change: 0 additions & 1 deletion src/warmac/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
# The current version of WarMAC
VERSION = "0.0.5"

# Convert to a match case when 3.9 EOL. Default case raises error
AVERAGE_FUNCTIONS: Mapping[AverageKind, Callable[[Sequence[int]], float]] = {
"geometric": statistics.geometric_mean,
"mean": statistics.mean,
Expand Down
13 changes: 11 additions & 2 deletions tests/test_average.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,10 @@ def test_in_time_range_should_be_bool(
def test_invalid_isoformat_raises_value_error(self) -> None:
"""Test that ValueError is raised for completely malformed
ISO-8601 timestamps.""" # noqa: D205, D209
match_string = "Invalid isoformat string: 'not-a-valid-timestamp'"
match_string = (
r"Invalid isoformat string: 'not-a-valid-timestamp'|Unknown string format:"
r" not-a-valid-timestamp"
)
with pytest.raises(ValueError, match=match_string):
average.in_time_range("not-a-valid-timestamp", self.TEST_CURRENT_TIME)

Expand Down Expand Up @@ -598,7 +601,13 @@ def test_empty_plat_list_raises_error(mock_args: argparse.Namespace) -> None:
mock_args.item = "Nonexistent Item"
mock_args.detailed_report = True

with pytest.raises(ValueError, match=r"max\(\) iterable argument is empty"):
with pytest.raises(
ValueError,
match=(
r"(max\(\) iterable argument is empty)|(max\(\) arg is an empty "
r"sequence)"
),
):
average.format_output(stat, plat_list, mock_args)

@staticmethod
Expand Down
Loading