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

Commit

Permalink
Apply black
Browse files Browse the repository at this point in the history
  • Loading branch information
PerchunPak committed Feb 18, 2022
1 parent 51c31c1 commit 00907e0
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 22 deletions.
27 changes: 16 additions & 11 deletions autodonate/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,9 @@ def __init__(self) -> None:
# looking for a config
# determining the default value
# if there "DONATE_CONFIG" use it
if environ.get("DONATE_CONFIG") and Path(environ["DONATE_CONFIG"]).is_file(): # noqa: E501
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
Expand All @@ -150,16 +152,19 @@ def __init__(self) -> None:
self._load()
else:
log.warning(
"The config file was not found. Specify the path to it using " +
"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
"The config file was not found. Specify the path to it using "
+ "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
)
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) + # noqa: WPS323 E501
"as config") # noqa: WPS319 WPS318
log.warning(
'config.toml.example found, copied to "%s" and used '
% str(self.CONFIG_PATH)
+ "as config" # noqa: WPS323 E501
) # noqa: WPS319 WPS318
self._load()

self.inter: ConfigIntermediate = ConfigIntermediate(config=self.CONFIG)
Expand Down Expand Up @@ -202,8 +207,8 @@ def _check(self) -> None:
self["ALLOWED_HOSTS"] # noqa: WPS428
except ConfigVariableNotFoundError:
log.fatal(
"The main variables in the config are not configured. " +
"The site cannot work without them, see Documentation " +
"(https://autodonate.readthedocs.io/en/latest/) for help.",
"The main variables in the config are not configured. "
+ "The site cannot work without them, see Documentation "
+ "(https://autodonate.readthedocs.io/en/latest/) for help.",
)
exit(1) # noqa: WPS421
11 changes: 8 additions & 3 deletions autodonate/lib/utils/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,16 @@ def get_logger(name: str):
logger = getLogger(name)
logger.setLevel(INFO)
file_handler = FileHandler(
filename="{0}{1}".format(str(BASE_DIR / "logs" / name), ".log"), encoding="utf8", # noqa: E501
filename="{0}{1}".format(str(BASE_DIR / "logs" / name), ".log"),
encoding="utf8", # noqa: E501
)
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"
) # noqa: WPS323,E501
console_formatter = Formatter(
"[{0}:%(levelname)s] %(message)s".format(name)
) # noqa: WPS323,E501
file_handler.setFormatter(file_formatter)
console_handler.setFormatter(console_formatter)
logger.addHandler(file_handler)
Expand Down
4 changes: 0 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,12 @@ def _get_project_meta():
"sphinx.ext.coverage",
"sphinx.ext.viewcode",
"sphinx.ext.autosummary",

# Used to write beautiful docstrings:
"sphinx.ext.napoleon",

# Used to include .md files:
"m2r2",

# Used to insert typehints into the final docs:
"sphinx_autodoc_typehints",

# Run sphinx-apidoc on each build:
"sphinxcontrib.apidoc",
]
Expand Down
6 changes: 3 additions & 3 deletions manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ def main():
)
except ImportError as exc: # noqa: I005
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?",
"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?",
) from exc
execute_from_command_line(sys.argv)

Expand Down
4 changes: 3 additions & 1 deletion tests/config/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,7 @@ def test_config_converter() -> None:
assert ConfigIntermediate._process_answer("list:1,2") == ["1", "2"]
assert ConfigIntermediate._process_answer("bool:1") is True
assert ConfigIntermediate._process_answer("bool:0") is False
assert ConfigIntermediate._process_answer('json:{"key":"value"}') == {"key": "value"} # noqa: E501
assert ConfigIntermediate._process_answer('json:{"key":"value"}') == {
"key": "value"
} # noqa: E501
assert ConfigIntermediate._process_answer("null:") is None

0 comments on commit 00907e0

Please sign in to comment.