Skip to content

Commit

Permalink
More code imporvements
Browse files Browse the repository at this point in the history
  • Loading branch information
jpintor52 committed Feb 15, 2024
1 parent 1346676 commit 6f62916
Show file tree
Hide file tree
Showing 13 changed files with 66 additions and 27 deletions.
12 changes: 6 additions & 6 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
master_doc = 'index'

# General information about the project.
project = u'Django Suit'
copyright = u'2013, Kaspars Sprogis (darklow)'
project = 'Django Suit'
copyright = '2013, Kaspars Sprogis (darklow)'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -188,7 +188,7 @@
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'DjangoSuit.tex', u'Django Suit Documentation', u'Kaspars Sprogis (darklow)', 'manual'),
('index', 'DjangoSuit.tex', 'Django Suit Documentation', 'Kaspars Sprogis (darklow)', 'manual'),
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down Expand Up @@ -216,7 +216,7 @@

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [('index', 'djangosuit', u'Django Suit Documentation', [u'Kaspars Sprogis (darklow)'], 1)]
man_pages = [('index', 'djangosuit', 'Django Suit Documentation', ['Kaspars Sprogis (darklow)'], 1)]

# If true, show URL addresses after external links.
# man_show_urls = False
Expand All @@ -231,8 +231,8 @@
(
'index',
'DjangoSuit',
u'Django Suit Documentation',
u'Kaspars Sprogis (darklow)',
'Django Suit Documentation',
'Kaspars Sprogis (darklow)',
'DjangoSuit',
'One line description of project.',
'Miscellaneous',
Expand Down
34 changes: 34 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[tool.ruff]
# https://docs.astral.sh/ruff/configuration/#using-pyprojecttoml

fix = true

ignore = [
"E203", # Whitespace before '{symbol}'
"F401", # {name} imported but unused
]

line-length = 120

# https://docs.astral.sh/ruff/rules/
select = [
# First two lines represent default flake8 configuration
"E", "W", # PyCodestyle
"F", # PyFlakes
"T10", # flake8-debugger: catch debug statements
"T20", # flake8-print: catch print statements
"UP025", # unicode-kind-prefix: Prevent unicode prefix in strings
"I", # isort: Check import order and add missing required imports
]

show-fixes = true

[tool.ruff.isort]
# https://docs.astral.sh/ruff/settings/#isort
# Combine aliased imports into the same import statement.
combine-as-imports = true
# With imports including at least one alias, force each imported member to its own line.
force-wrap-aliases = true
# Do not sort imports by type (constant, class, function, etc.).
# Instead, sort them alphabetically and case-insensitively.
order-by-type = false
8 changes: 5 additions & 3 deletions suit/admin.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import copy

from django.conf import settings
from django.contrib import admin
from django.contrib.admin import ModelAdmin
from django.contrib.admin.views.main import ChangeList
from django.forms import ModelForm
from django.contrib import admin
from django.db import models
from suit.widgets import NumberInput, SuitSplitDateTimeWidget
from django.forms import ModelForm

from suit.compat import ct_admin
from suit.widgets import NumberInput, SuitSplitDateTimeWidget


class SortableModelAdminBase(object):
Expand Down
2 changes: 1 addition & 1 deletion suit/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"""
import django
from django.template.defaulttags import url
from django.contrib.contenttypes import admin as ct_admin
from django.template.defaulttags import url

tpl_context_class = dict
10 changes: 6 additions & 4 deletions suit/config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.contrib.admin import ModelAdmin
from django.conf import settings
from django.contrib.admin import ModelAdmin

from . import VERSION


Expand Down Expand Up @@ -55,10 +56,11 @@ def get_config(param=None):


def setup_filer():
from suit.widgets import AutosizedTextarea
from filer.admin.imageadmin import ImageAdminForm
from filer.admin.fileadmin import FileAdminChangeFrom
from filer.admin import FolderAdmin
from filer.admin.fileadmin import FileAdminChangeFrom
from filer.admin.imageadmin import ImageAdminForm

from suit.widgets import AutosizedTextarea

def ensure_meta_widgets(meta_cls):
if not hasattr(meta_cls, 'widgets'):
Expand Down
1 change: 1 addition & 0 deletions suit/templatetags/suit_compat.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django import template

from ..compat import url as url_compat

register = template.Library()
Expand Down
4 changes: 3 additions & 1 deletion suit/templatetags/suit_tags.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import itertools

from django import template
from django.core.exceptions import ObjectDoesNotExist
from django.db.models import ForeignKey
from django.template.defaulttags import NowNode
from django.utils.safestring import mark_safe
from suit.config import get_config

from suit import utils
from suit.config import get_config

try:
from django.core.urlresolvers import NoReverseMatch, reverse
Expand Down
5 changes: 3 additions & 2 deletions suit/tests/config.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from django.contrib.admin import ModelAdmin
from django.conf import settings
from django.contrib.admin import ModelAdmin

from suit import VERSION
from suit.config import default_config, get_config
from suit.templatetags.suit_tags import admin_url
from suit.tests.mixins import ModelsTestCaseMixin, UserTestCaseMixin
from suit.tests.models import Book
from suit.tests.mixins import UserTestCaseMixin, ModelsTestCaseMixin


class ConfigTestCase(UserTestCaseMixin):
Expand Down
6 changes: 3 additions & 3 deletions suit/tests/mixins.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from random import randint

from django.conf import settings
from django.contrib.auth.models import User
from django.core.management import CommandError
from django.core.management import call_command
from django.core.management import call_command, CommandError
from django.test import TestCase
from random import randint

# Django 1.7 compatiblity
try:
Expand Down
1 change: 1 addition & 0 deletions suit/tests/templates/form_tabs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.contrib import admin
from django.utils.translation import gettext

from suit.tests.mixins import ModelsTestCaseMixin, UserTestCaseMixin
from suit.tests.models import Book, BookAdmin, test_app_label

Expand Down
3 changes: 0 additions & 3 deletions suit/tests/test.py
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
from .templatetags import *
from .templates import *
from . import *
2 changes: 1 addition & 1 deletion suit/tests/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django import get_version
from suit import utils
from django.test import TestCase

from suit import utils
from suit.templatetags.suit_tags import str_to_version


Expand Down
5 changes: 2 additions & 3 deletions suit/watch_less.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import sys
import os
import sys
import time

from watchdog.events import FileModifiedEvent, FileSystemEventHandler
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler, FileModifiedEvent


class LessCompiler(FileSystemEventHandler):
Expand All @@ -17,7 +17,6 @@ def compile_css(self):
else:
destination = sys.argv[2]
cmd = 'lessc %s > %s -x' % (source, os.path.abspath(destination))
print(cmd)
os.system(cmd)

def on_any_event(self, event):
Expand Down

0 comments on commit 6f62916

Please sign in to comment.