Skip to content

Commit

Permalink
Add ruff linter. (#956)
Browse files Browse the repository at this point in the history
  • Loading branch information
TyVik authored Oct 15, 2023
1 parent 08e8b8c commit 0540c0b
Show file tree
Hide file tree
Showing 9 changed files with 109 additions and 48 deletions.
20 changes: 20 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,23 @@ jobs:
name: Run pylint
command: PYTHONPATH="$PYTHONPATH:." pylint --rcfile pyproject.toml common maps mercator puzzle quiz users workshop

ruff:
docker:
- image: tyvik/geopuzzle:backend-tester
environment:
DJANGO_SETTINGS_MODULE: "mercator.settings.circleci"
SECRET_KEY: "mY_sup#r_sec3t+KEY"
working_directory: ~/repo
resource_class: small
steps:
- checkout
- run:
name: Prepare environment
command: mkdir ~/repo/logs
- run:
name: Run ruff
command: PYTHONPATH="$PYTHONPATH:." ruff check .

messages:
docker:
- image: tyvik/geopuzzle:backend
Expand Down Expand Up @@ -214,6 +231,9 @@ workflows:
- pylint:
requires:
- build-backend
- ruff:
requires:
- build-backend
- messages:
requires:
- build-backend
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[![BrowserStack Status](https://www.browserstack.com/automate/badge.svg?badge_key=Fbm86tXoBBqACUnFaJqP)](https://www.browserstack.com/automate/public-build/Fbm86tXoBBqACUnFaJqP)
[![codecov](https://codecov.io/gh/TyVik/geopuzzle/branch/develop/graph/badge.svg)](https://codecov.io/gh/TyVik/geopuzzle)
[![linting: pylint](https://img.shields.io/badge/linting-pylint-yellowgreen)](https://github.com/pylint-dev/pylint)

[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)

[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=TyVik_geopuzzle&metric=sqale_rating)](https://sonarcloud.io/dashboard?id=TyVik_geopuzzle)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=TyVik_geopuzzle&metric=alert_status)](https://sonarcloud.io/dashboard?id=TyVik_geopuzzle)
Expand Down
17 changes: 2 additions & 15 deletions manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,9 @@
import os
import sys

from django.core.management import execute_from_command_line


if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mercator.settings.development")
try:
from django.core.management import execute_from_command_line
except ImportError:
# The above import may fail for some other reason. Ensure that the
# issue is really that Django is missing to avoid masking other
# exceptions on Python 2.
try:
import django # lgtm [py/unused-import]
except ImportError:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
)
raise
execute_from_command_line(sys.argv)
14 changes: 12 additions & 2 deletions maps/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,18 @@
from .models import Region, RegionTranslation

POINTS = (
([-2.4610019, 49.4612907], [-2.4610233, 49.4613325], [-2.4628043, 49.4608862], [-2.4634051, 49.4606073], [-2.4640274, 49.4606491], [-2.4642205, 49.4599378], [-2.4651432, 49.4597984], [-2.4651861, 49.4587523], [-2.4658513, 49.4584455], [-2.4653149, 49.4574273], [-2.4653149, 49.4564509], [-2.4643064, 49.4562138], [-2.4639845, 49.4557954], [-2.4626756, 49.4559349], [-2.462461, 49.4563533], [-2.4618816, 49.4569531], [-2.4607658, 49.456967], [-2.46068, 49.4574691], [-2.4605298, 49.4577063], [-2.46068, 49.4578178], [-2.460444, 49.4580828], [-2.4600363, 49.4579434], [-2.4595642, 49.4580828], [-2.4595213, 49.4583339], [-2.4594784, 49.458836], [-2.4592209, 49.4590452], [-2.4592209, 49.4593242], [-2.4590921, 49.4595055], [-2.4593067, 49.4597147], [-2.4596715, 49.4599239], [-2.45965, 49.4602168], [-2.4598861, 49.4603981], [-2.4602509, 49.4604678], [-2.4603367, 49.460677], [-2.4608088, 49.4609002], [-2.4610019, 49.4612907]), # pylint: disable=line-too-long
([-2.4636197, 49.4623646], [-2.4636412, 49.4626086], [-2.4640059, 49.4627411], [-2.4646497, 49.4634384], [-2.4650359, 49.4632292], [-2.4655938, 49.4631734], [-2.4655402, 49.462769], [-2.4655831, 49.4624761], [-2.4647677, 49.4621205], [-2.4640918, 49.4624831], [-2.4636197, 49.4623646]) # pylint: disable=line-too-long
([-2.4610019, 49.4612907], [-2.4610233, 49.4613325], [-2.4628043, 49.4608862], [-2.4634051, 49.4606073],
[-2.4640274, 49.4606491], [-2.4642205, 49.4599378], [-2.4651432, 49.4597984], [-2.4651861, 49.4587523],
[-2.4658513, 49.4584455], [-2.4653149, 49.4574273], [-2.4653149, 49.4564509], [-2.4643064, 49.4562138],
[-2.4639845, 49.4557954], [-2.4626756, 49.4559349], [-2.462461, 49.4563533], [-2.4618816, 49.4569531],
[-2.4607658, 49.456967], [-2.46068, 49.4574691], [-2.4605298, 49.4577063], [-2.46068, 49.4578178],
[-2.460444, 49.4580828], [-2.4600363, 49.4579434], [-2.4595642, 49.4580828], [-2.4595213, 49.4583339],
[-2.4594784, 49.458836], [-2.4592209, 49.4590452], [-2.4592209, 49.4593242], [-2.4590921, 49.4595055],
[-2.4593067, 49.4597147], [-2.4596715, 49.4599239], [-2.45965, 49.4602168], [-2.4598861, 49.4603981],
[-2.4602509, 49.4604678], [-2.4603367, 49.460677], [-2.4608088, 49.4609002], [-2.4610019, 49.4612907]),
([-2.4636197, 49.4623646], [-2.4636412, 49.4626086], [-2.4640059, 49.4627411], [-2.4646497, 49.4634384],
[-2.4650359, 49.4632292], [-2.4655938, 49.4631734], [-2.4655402, 49.462769], [-2.4655831, 49.4624761],
[-2.4647677, 49.4621205], [-2.4640918, 49.4624831], [-2.4636197, 49.4623646])
)
INFOBOX = {
"area": "178",
Expand Down
2 changes: 1 addition & 1 deletion maps/management/commands/cache.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json

from django.core.cache import cache
from django.core.management import BaseCommand, CommandError
from django.core.management import BaseCommand
from tqdm import tqdm

from maps.models import Region
Expand Down
3 changes: 3 additions & 0 deletions maps/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from .game import Game, GameTranslation
from .region import Region, RegionInterface, RegionTranslation, RegionCache
from .tag import Tag


__all__ = ["Game", "GameTranslation", "Region", "RegionInterface", "RegionTranslation", "RegionCache", "Tag"]
1 change: 1 addition & 0 deletions maps/tests/test_decoder.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# ruff: noqa: E501
import json
from typing import List
from unittest import TestCase
Expand Down
83 changes: 54 additions & 29 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ lint = [
"django-stubs",
"pylint",
"pylint-django",
"ruff"
]
test = [
"codecov",
Expand Down Expand Up @@ -146,3 +147,17 @@ ignore-imports = false

[tool.pylint.IMPORTS]
deprecated-modules = ["optparse", "tkinter.tix"]

[tool.ruff]
line-length = 120
target-version = "py311"
exclude = [
".git",
".mypy_cache",
".ruff_cache",
"__pypackages__",
"node_modules",
"migrations",
"pgdata",
"settings"
]

0 comments on commit 0540c0b

Please sign in to comment.