Skip to content

Commit

Permalink
enable more ruffs
Browse files Browse the repository at this point in the history
  • Loading branch information
benzkji committed Jan 22, 2024
1 parent dce8aca commit f4df881
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 20 deletions.
4 changes: 2 additions & 2 deletions postgres_searchindex/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class SourceAlreadyRegistered(Exception):
class SourceAlreadyRegisteredError(Exception):
pass


class SourceNotRegistered(Exception):
class SourceNotRegisteredError(Exception):
pass
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,4 @@ class Command(BaseCommand):
help = "Try send something to Sentry!"

def handle(self, *args, **options):
from xxx import yyy # noqa

return
pass
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def handle(self, *args, **options):
self.stdout.write(
f"Updating index \"{index_key}\" with kwargs {index.get('kwargs', {})}"
)
for source_name, source_cls in source_pool.get_sources().items():
for source_cls in source_pool.get_sources().values():
source = source_cls(**index.get("kwargs", {}))
self.stdout.write(
f"{source.model.__name__}. "
Expand Down
8 changes: 4 additions & 4 deletions postgres_searchindex/source_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

from postgres_searchindex.base import IndexSource
from postgres_searchindex.exceptions import (
SourceAlreadyRegistered,
SourceNotRegistered,
SourceAlreadyRegisteredError,
SourceNotRegisteredError,
)
from postgres_searchindex.models import IndexEntry

Expand Down Expand Up @@ -37,7 +37,7 @@ def register(self, source):
)
source_name = source.__name__
if source_name in self.sources:
raise SourceAlreadyRegistered(
raise SourceAlreadyRegisteredError(
"Cannot register {!r}, an source with this name ({!r}) is already "
"registered.".format(source, source_name)
)
Expand Down Expand Up @@ -66,7 +66,7 @@ def unregister(self, source):
"""
source_name = source.__name__
if source_name not in self.sources:
raise SourceNotRegistered("The source %r is not registered" % source)
raise SourceNotRegisteredError("The source %r is not registered" % source)
del self.sources[source_name]

def get_sources(self):
Expand Down
16 changes: 8 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,29 @@ select = [
# isort
"I",
# pep8-naming
# "N",
"N",
# pyupgrade
# "UP",
"UP",
# flake8-2020
"YTT",
# flake8-boolean-trap
# "FBT",
"FBT",
# flake8-bugbear
# "B",
"B",
# flake8-comprehensions
"C4",
# flake8-django
"DJ",
# flake8-pie
# "PIE",
"PIE",
# flake8-simplify
# "SIM",
"SIM",
# flake8-gettext
"INT",
# pygrep-hooks
# "PGH",
"PGH",
# pylint
# "PL",
"PL",
# unused noqa
"RUF100",
# flake8-print
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- encoding: utf-8 -*-
"""
Python setup file for the postgres_searchindex app.
Expand Down Expand Up @@ -36,7 +35,8 @@

def read(fname):
# read the contents of a text file
return open(os.path.join(os.path.dirname(__file__), fname)).read()
with open(os.path.join(os.path.dirname(__file__), fname)) as file:
return file.read()


install_requires = [
Expand Down

0 comments on commit f4df881

Please sign in to comment.