Skip to content

Commit

Permalink
Merge pull request #124 from michael-lazar/linters
Browse files Browse the repository at this point in the history
Upgrade to python 3.10 and add linters/tooling
  • Loading branch information
michael-lazar committed Jan 9, 2024
2 parents a35f2ba + 7d1c903 commit 52cb737
Show file tree
Hide file tree
Showing 116 changed files with 314 additions and 231 deletions.
30 changes: 15 additions & 15 deletions .github/workflows/astrobotany.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.7
uses: actions/setup-python@v1
- name: Check out repository
uses: actions/checkout@v2
- name: Install python
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Install packages
run: |
pip install .
pip install .[test]
sudo apt-get install timidity
- name: Lint with mypy
run: |
mypy --ignore-missing-imports --exclude build .
- name: Run tests
run: |
pytest -v tests/
python-version: '3.10'
- name: Run pre-commit checks
uses: pre-commit/actions@v2.0.3
- name: Run bootstrap
run: tools/bootstrap
- name: Install timidity
run: sudo apt-get install timidity
- name: Run mypy
run: tools/mypy
- name: Run pytest
run: tools/pytest
29 changes: 29 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
default_stages: [commit]

default_language_version:
python: python3.10

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: file-contents-sorter
files: requirements/.*\.in

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.1.4
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]

- repo: https://github.com/psf/black
rev: 23.10.1
hooks:
- id: black

ci:
autoupdate_schedule: weekly
skip: []
submodules: false
4 changes: 2 additions & 2 deletions astrobotany/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .models import init_db
from .views import app
from astrobotany.models import init_db
from astrobotany.views import app

__all__ = ["init_db", "app"]
11 changes: 4 additions & 7 deletions astrobotany/art.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
import itertools
import json
import os
import random
from typing import Dict, List, NamedTuple, Optional, Tuple
from typing import Dict, List, NamedTuple, Tuple

ColorCode = Optional[int]
ColorCode = int | None


class Tile(NamedTuple):
Expand Down Expand Up @@ -77,7 +76,7 @@ class ArtFile:
# randomness to the order of colors for rainbow plants
rainbow_generator = itertools.cycle(RAINBOW_COLORS)

def __init__(self, filename: str, flower_color: Optional[str] = None) -> None:
def __init__(self, filename: str, flower_color: str | None = None) -> None:
self.filename = filename
self.flower_color = flower_color
self.character_matrix = self.load_file(filename)
Expand Down Expand Up @@ -196,7 +195,5 @@ def merge_tiles(cls, character_matrix: CharacterMatrix) -> CharacterMatrix:


@functools.lru_cache(maxsize=1000)
def render_art(
filename: str, flower_color: Optional[str] = None, ansi_enabled: bool = False
) -> str:
def render_art(filename: str, flower_color: str | None = None, ansi_enabled: bool = False) -> str:
return ArtFile(filename, flower_color).render(ansi_enabled)
2 changes: 1 addition & 1 deletion astrobotany/art/agave1.psci
Original file line number Diff line number Diff line change
Expand Up @@ -1528,4 +1528,4 @@
"selected_fg_color": 73,
"selected_xform": 0,
"width": 25
}
}
2 changes: 1 addition & 1 deletion astrobotany/art/agave2.psci
Original file line number Diff line number Diff line change
Expand Up @@ -1528,4 +1528,4 @@
"selected_fg_color": 80,
"selected_xform": 0,
"width": 25
}
}
2 changes: 1 addition & 1 deletion astrobotany/art/agave3.psci
Original file line number Diff line number Diff line change
Expand Up @@ -1528,4 +1528,4 @@
"selected_fg_color": 122,
"selected_xform": 0,
"width": 25
}
}
2 changes: 1 addition & 1 deletion astrobotany/art/aloe1.psci
Original file line number Diff line number Diff line change
Expand Up @@ -1528,4 +1528,4 @@
"selected_fg_color": 80,
"selected_xform": 0,
"width": 25
}
}
2 changes: 1 addition & 1 deletion astrobotany/art/aloe2.psci
Original file line number Diff line number Diff line change
Expand Up @@ -1528,4 +1528,4 @@
"selected_fg_color": 80,
"selected_xform": 0,
"width": 25
}
}
2 changes: 1 addition & 1 deletion astrobotany/art/aloe3.psci
Original file line number Diff line number Diff line change
Expand Up @@ -1528,4 +1528,4 @@
"selected_fg_color": 199,
"selected_xform": 0,
"width": 25
}
}
2 changes: 1 addition & 1 deletion astrobotany/art/baobab1.psci
Original file line number Diff line number Diff line change
Expand Up @@ -1528,4 +1528,4 @@
"selected_fg_color": 13,
"selected_xform": 0,
"width": 25
}
}
2 changes: 1 addition & 1 deletion astrobotany/art/baobab2.psci
Original file line number Diff line number Diff line change
Expand Up @@ -1528,4 +1528,4 @@
"selected_fg_color": 13,
"selected_xform": 0,
"width": 25
}
}
2 changes: 1 addition & 1 deletion astrobotany/art/baobab3.psci
Original file line number Diff line number Diff line change
Expand Up @@ -1528,4 +1528,4 @@
"selected_fg_color": 199,
"selected_xform": 0,
"width": 25
}
}
2 changes: 1 addition & 1 deletion astrobotany/art/bee.psci
Original file line number Diff line number Diff line change
Expand Up @@ -1684,4 +1684,4 @@
"selected_fg_color": 65,
"selected_xform": 0,
"width": 23
}
}
2 changes: 1 addition & 1 deletion astrobotany/art/brugmansia1.psci
Original file line number Diff line number Diff line change
Expand Up @@ -1528,4 +1528,4 @@
"selected_fg_color": 62,
"selected_xform": 0,
"width": 25
}
}
2 changes: 1 addition & 1 deletion astrobotany/art/brugmansia2.psci
Original file line number Diff line number Diff line change
Expand Up @@ -1528,4 +1528,4 @@
"selected_fg_color": 62,
"selected_xform": 0,
"width": 25
}
}
2 changes: 1 addition & 1 deletion astrobotany/art/brugmansia3.psci
Original file line number Diff line number Diff line change
Expand Up @@ -1528,4 +1528,4 @@
"selected_fg_color": 199,
"selected_xform": 0,
"width": 25
}
}
2 changes: 1 addition & 1 deletion astrobotany/art/cactus1.psci
Original file line number Diff line number Diff line change
Expand Up @@ -1528,4 +1528,4 @@
"selected_fg_color": 14,
"selected_xform": 0,
"width": 25
}
}
2 changes: 1 addition & 1 deletion astrobotany/art/cactus2.psci
Original file line number Diff line number Diff line change
Expand Up @@ -1528,4 +1528,4 @@
"selected_fg_color": 80,
"selected_xform": 0,
"width": 25
}
}
2 changes: 1 addition & 1 deletion astrobotany/art/cactus3.psci
Original file line number Diff line number Diff line change
Expand Up @@ -1528,4 +1528,4 @@
"selected_fg_color": 199,
"selected_xform": 0,
"width": 25
}
}
2 changes: 1 addition & 1 deletion astrobotany/art/christmas.psci
Original file line number Diff line number Diff line change
Expand Up @@ -6778,4 +6778,4 @@
"selected_fg_color": 25,
"selected_xform": 0,
"width": 45
}
}
2 changes: 1 addition & 1 deletion astrobotany/art/columbine1.psci
Original file line number Diff line number Diff line change
Expand Up @@ -1528,4 +1528,4 @@
"selected_fg_color": 80,
"selected_xform": 0,
"width": 25
}
}
2 changes: 1 addition & 1 deletion astrobotany/art/columbine2.psci
Original file line number Diff line number Diff line change
Expand Up @@ -1528,4 +1528,4 @@
"selected_fg_color": 55,
"selected_xform": 0,
"width": 25
}
}
2 changes: 1 addition & 1 deletion astrobotany/art/columbine3.psci
Original file line number Diff line number Diff line change
Expand Up @@ -1528,4 +1528,4 @@
"selected_fg_color": 199,
"selected_xform": 0,
"width": 25
}
}
2 changes: 1 addition & 1 deletion astrobotany/art/daffodil1.psci
Original file line number Diff line number Diff line change
Expand Up @@ -1528,4 +1528,4 @@
"selected_fg_color": 80,
"selected_xform": 0,
"width": 25
}
}
2 changes: 1 addition & 1 deletion astrobotany/art/daffodil2.psci
Original file line number Diff line number Diff line change
Expand Up @@ -1528,4 +1528,4 @@
"selected_fg_color": 14,
"selected_xform": 0,
"width": 25
}
}
2 changes: 1 addition & 1 deletion astrobotany/art/daffodil3.psci
Original file line number Diff line number Diff line change
Expand Up @@ -1528,4 +1528,4 @@
"selected_fg_color": 133,
"selected_xform": 0,
"width": 25
}
}
1 change: 0 additions & 1 deletion astrobotany/art/duck.psci
Original file line number Diff line number Diff line change
Expand Up @@ -1163,4 +1163,3 @@
"selected_xform": 0,
"width": 27
}

2 changes: 1 addition & 1 deletion astrobotany/art/epilog1.psci
Original file line number Diff line number Diff line change
Expand Up @@ -1150,4 +1150,4 @@
"selected_fg_color": 19,
"selected_xform": 0,
"width": 17
}
}
2 changes: 1 addition & 1 deletion astrobotany/art/epilog2.psci
Original file line number Diff line number Diff line change
Expand Up @@ -1546,4 +1546,4 @@
"selected_fg_color": 216,
"selected_xform": 0,
"width": 23
}
}
2 changes: 1 addition & 1 deletion astrobotany/art/epilog3.psci
Original file line number Diff line number Diff line change
Expand Up @@ -1612,4 +1612,4 @@
"selected_fg_color": 216,
"selected_xform": 0,
"width": 24
}
}
2 changes: 1 addition & 1 deletion astrobotany/art/epilog4.psci
Original file line number Diff line number Diff line change
Expand Up @@ -1150,4 +1150,4 @@
"selected_fg_color": 19,
"selected_xform": 0,
"width": 17
}
}
2 changes: 1 addition & 1 deletion astrobotany/art/fern1.psci
Original file line number Diff line number Diff line change
Expand Up @@ -1528,4 +1528,4 @@
"selected_fg_color": 80,
"selected_xform": 0,
"width": 25
}
}
2 changes: 1 addition & 1 deletion astrobotany/art/fern2.psci
Original file line number Diff line number Diff line change
Expand Up @@ -1528,4 +1528,4 @@
"selected_fg_color": 80,
"selected_xform": 0,
"width": 25
}
}
2 changes: 1 addition & 1 deletion astrobotany/art/fern3.psci
Original file line number Diff line number Diff line change
Expand Up @@ -1528,4 +1528,4 @@
"selected_fg_color": 199,
"selected_xform": 0,
"width": 25
}
}
2 changes: 1 addition & 1 deletion astrobotany/art/ficus1.psci
Original file line number Diff line number Diff line change
Expand Up @@ -1588,4 +1588,4 @@
"selected_fg_color": 94,
"selected_xform": 0,
"width": 26
}
}
2 changes: 1 addition & 1 deletion astrobotany/art/ficus2.psci
Original file line number Diff line number Diff line change
Expand Up @@ -1948,4 +1948,4 @@
"selected_fg_color": 94,
"selected_xform": 0,
"width": 32
}
}
2 changes: 1 addition & 1 deletion astrobotany/art/ficus3.psci
Original file line number Diff line number Diff line change
Expand Up @@ -1948,4 +1948,4 @@
"selected_fg_color": 94,
"selected_xform": 0,
"width": 32
}
}
2 changes: 1 addition & 1 deletion astrobotany/art/hemp1.psci
Original file line number Diff line number Diff line change
Expand Up @@ -1528,4 +1528,4 @@
"selected_fg_color": 20,
"selected_xform": 0,
"width": 25
}
}
2 changes: 1 addition & 1 deletion astrobotany/art/hemp2.psci
Original file line number Diff line number Diff line change
Expand Up @@ -1528,4 +1528,4 @@
"selected_fg_color": 20,
"selected_xform": 0,
"width": 25
}
}
2 changes: 1 addition & 1 deletion astrobotany/art/hemp3.psci
Original file line number Diff line number Diff line change
Expand Up @@ -1528,4 +1528,4 @@
"selected_fg_color": 199,
"selected_xform": 0,
"width": 25
}
}
2 changes: 1 addition & 1 deletion astrobotany/art/iris1.psci
Original file line number Diff line number Diff line change
Expand Up @@ -1528,4 +1528,4 @@
"selected_fg_color": 62,
"selected_xform": 0,
"width": 25
}
}
2 changes: 1 addition & 1 deletion astrobotany/art/iris2.psci
Original file line number Diff line number Diff line change
Expand Up @@ -1528,4 +1528,4 @@
"selected_fg_color": 80,
"selected_xform": 0,
"width": 25
}
}
2 changes: 1 addition & 1 deletion astrobotany/art/iris3.psci
Original file line number Diff line number Diff line change
Expand Up @@ -1528,4 +1528,4 @@
"selected_fg_color": 199,
"selected_xform": 0,
"width": 25
}
}
2 changes: 1 addition & 1 deletion astrobotany/art/jackolantern.psci
Original file line number Diff line number Diff line change
Expand Up @@ -1768,4 +1768,4 @@
"selected_fg_color": 164,
"selected_xform": 0,
"width": 29
}
}
2 changes: 1 addition & 1 deletion astrobotany/art/jadeplant1.psci
Original file line number Diff line number Diff line change
Expand Up @@ -1528,4 +1528,4 @@
"selected_fg_color": 79,
"selected_xform": 0,
"width": 25
}
}
Loading

0 comments on commit 52cb737

Please sign in to comment.