Skip to content
This repository has been archived by the owner on Jul 18, 2022. It is now read-only.

Commit

Permalink
Remove flake8 bullshit 🔥
Browse files Browse the repository at this point in the history
  • Loading branch information
cofob committed Feb 19, 2022
1 parent 8315e0a commit 62ab7d1
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 27 deletions.
22 changes: 11 additions & 11 deletions autodonate/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

# We are re-creating BASE_DIR due to a circular import
# from settings.py
BASE_DIR = Path(__file__).resolve().parent.parent # noqa: WPS462
BASE_DIR = Path(__file__).resolve().parent.parent


class ConfigVariableNotFoundError(Exception):
Expand Down Expand Up @@ -77,7 +77,7 @@ def __getitem__(self, config_item: str) -> Any: # type: ignore[misc]

raise ConfigVariableNotFoundError("`self.config` is not set.")

def get(self, config_item: str, default: Any = ConfigNone) -> Any: # type: ignore[misc] # noqa: E501
def get(self, config_item: str, default: Any = ConfigNone) -> Any: # type: ignore[misc]
"""Return the value for key if key is in the dictionary, else default.
Args:
Expand All @@ -98,7 +98,7 @@ def get(self, config_item: str, default: Any = ConfigNone) -> Any: # type: igno
return default

@staticmethod
def _process_answer(answer: object) -> Any: # type: ignore[misc] # noqa: WPS602,WPS212,E501
def _process_answer(answer: object) -> Any: # type: ignore[misc]
"""Breaking the boundaries given to us by environ.
Args:
Expand Down Expand Up @@ -144,12 +144,12 @@ def __init__(self) -> None:
# if there "DONATE_CONFIG" use it
if (
environ.get("DONATE_CONFIG") and Path(environ["DONATE_CONFIG"]).is_file()
): # noqa: E501
):
self.CONFIG_PATH: Path = Path(environ["DONATE_CONFIG"])
elif Path("/config/config.toml").is_file():
self.CONFIG_PATH: Path = Path("/config/config.toml") # type: ignore[no-redef] # no
self.CONFIG_PATH: Path = Path("/config/config.toml") # type: ignore[no-redef]
else:
self.CONFIG_PATH: Path = BASE_DIR / "config.toml" # type: ignore[no-redef] # noqa: E501
self.CONFIG_PATH: Path = BASE_DIR / "config.toml" # type: ignore[no-redef]

# loading the config
if self.CONFIG_PATH.exists():
Expand All @@ -160,15 +160,15 @@ def __init__(self) -> None:
+ "the DONATE_CONFIG environment variable, or add settings "
+ "directly to environment variables. You can get the actual "
+ "config from the link: "
+ "https://raw.githubusercontent.com/fire-squad/autodonate/master/config.toml", # noqa: E501
+ "https://raw.githubusercontent.com/fire-squad/autodonate/master/config.toml",
)
if (BASE_DIR / "config.toml.example").is_file():
copy_file(str(BASE_DIR / "config.toml.example"), str(self.CONFIG_PATH))
log.warning(
'config.toml.example found, copied to "%s" and used '
% str(self.CONFIG_PATH)
+ "as config" # noqa: WPS323 E501
) # noqa: WPS319 WPS318
+ "as config"
)
self._load()

self.inter: ConfigIntermediate = ConfigIntermediate(config=self.CONFIG)
Expand All @@ -185,7 +185,7 @@ def __getitem__(self, config_item: str) -> Any: # type: ignore[misc]
"""
return self.inter[config_item]

def get(self, config_item: str, default: Any = ConfigNone) -> Any: # type: ignore[misc] # noqa: E501
def get(self, config_item: str, default: Any = ConfigNone) -> Any: # type: ignore[misc]
"""Return the value for key if key is in the dictionary, else default.
Args:
Expand Down Expand Up @@ -217,4 +217,4 @@ def _check(self) -> None:
+ "The site cannot work without them, see Documentation "
+ "(https://autodonate.readthedocs.io/en/latest/) for help.",
)
exit(1) # noqa: WPS421
exit(1)
14 changes: 5 additions & 9 deletions autodonate/lib/utils/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,24 @@

# We are re-creating BASE_DIR due to a circular import
# from settings.py
BASE_DIR = Path(__file__).resolve().parent.parent.parent.parent # noqa: WPS462
BASE_DIR = Path(__file__).resolve().parent.parent.parent.parent


def get_logger(name: str):
"""Method for issuing a personal logger.
Taken from https://stackoverflow.com/questions/59254843/add-custom-log-records-in-django.
""" # noqa: E501
"""
(BASE_DIR / "logs").mkdir(exist_ok=True)
logger = getLogger(name)
logger.setLevel(INFO)
file_handler = FileHandler(
filename="{0}{1}".format(str(BASE_DIR / "logs" / name), ".log"),
encoding="utf8", # noqa: E501
encoding="utf8",
)
console_handler = StreamHandler()
file_formatter = Formatter(
"%(asctime)s [%(levelname)s] %(message)s"
) # noqa: WPS323,E501
console_formatter = Formatter(
"[{0}:%(levelname)s] %(message)s".format(name)
) # noqa: WPS323,E501
file_formatter = Formatter("%(asctime)s [%(levelname)s] %(message)s")
console_formatter = Formatter("[{0}:%(levelname)s] %(message)s".format(name))
file_handler.setFormatter(file_formatter)
console_handler.setFormatter(console_formatter)
logger.addHandler(file_handler)
Expand Down
8 changes: 4 additions & 4 deletions autodonate/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,16 @@

AUTH_PASSWORD_VALIDATORS = [
{
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator", # noqa: E501
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
},
{
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator", # noqa: E501
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
},
{
"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator", # noqa: E501
"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
},
{
"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator", # noqa: E501
"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
},
]

Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def _get_project_meta():

pkg_meta = _get_project_meta()
project = str(pkg_meta["name"])
copyright = "2022, firesquad" # noqa: WPS125
copyright = "2022, firesquad"
author = "firesquad"

# The short X.Y version
Expand Down
4 changes: 2 additions & 2 deletions manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ def main():
"""Run administrative tasks."""
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "autodonate.settings")
try:
from django.core.management import ( # noqa: WPS433
from django.core.management import (
execute_from_command_line,
)
except ImportError as exc: # noqa: I005
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
+ "available on your PYTHONPATH environment variable? Did you "
Expand Down

0 comments on commit 62ab7d1

Please sign in to comment.