Skip to content
Permalink
Browse files

style: Remove wemake-python-styleguide

* Remove wemake-python-styleguide
* Re-add some flake8 plugins that previously WPS pulled in
* Upgrade isort invocation
  • Loading branch information
oprypin committed Jan 3, 2021
1 parent 9590c80 commit 3ee6bf16839e4a79e04f98c61f3d80053b586f82
@@ -36,7 +36,7 @@ jobs:
uses: actions/cache@v1
with:
path: .venv
key: quality-venv-cache
key: quality-venv-cache-2

- name: Set up the project
run: |
@@ -14,7 +14,7 @@
from git_changelog.build import Changelog, Version
from jinja2 import StrictUndefined
from jinja2.sandbox import SandboxedEnvironment
from pip._internal.commands.show import search_packages_info # noqa: WPS436 (no other way?)
from pip._internal.commands.show import search_packages_info

PY_SRC_PATHS = (Path(_) for _ in ("src/mkdocstrings", "tests", "duties.py"))
PY_SRC_LIST = tuple(str(_) for _ in PY_SRC_PATHS)
@@ -287,7 +287,7 @@ def docs_regen(ctx):
url_prefix = "https://raw.githubusercontent.com/pawamoy/jinja-templates/master/"
regen_list = (("CREDITS.md", get_credits_data, url_prefix + "credits.md"),)

def regen() -> int: # noqa: WPS430 (nested function)
def regen() -> int:
"""
Regenerate pages listed in global `REGEN` list.
@@ -296,7 +296,7 @@ def regen() -> int: # noqa: WPS430 (nested function)
"""
env = SandboxedEnvironment(undefined=StrictUndefined)
for target, get_data, template in regen_list:
print("Regenerating", target) # noqa: WPS421 (print)
print("Regenerating", target)
template_data = get_data()
template_text = httpx.get(template).text
rendered = env.from_string(template_text).render(**template_data)
@@ -355,7 +355,7 @@ def format(ctx): # noqa: W0622 (we don't mind shadowing the format builtin)
title="Removing unused imports",
pty=PTY,
)
ctx.run(f"isort -y -rc {PY_SRC}", title="Ordering imports", pty=PTY)
ctx.run(f"isort {PY_SRC}", title="Ordering imports", pty=PTY)
ctx.run(f"black {PY_SRC}", title="Formatting code", pty=PTY)


@@ -40,8 +40,7 @@ flake8-pytest-style = "^1.3.0"
git-changelog = "^0.4.0"
httpx = "^0.14.3"
ipython = "^7.2"
# TODO: accept v5 once https://github.com/wemake-services/wemake-python-styleguide/issues/1584 is resolved
isort = {version = "<5", extras = ["pyproject"]}
isort = "^5.7.0"
jinja2-cli = "^0.7.0"
markdown-include = "^0.6.0"
mkdocs-material = "^5.5.12"
@@ -52,7 +51,13 @@ pytest-randomly = "^3.4.1"
pytest-sugar = "^0.9.4"
pytest-xdist = "^2.1.0"
toml = "^0.10.1"
wemake-python-styleguide = "^0.14.1"
darglint = "^1.5.8"
flake8-bandit = "^2.1.2"
flake8-bugbear = "^20.11.1"
flake8-comprehensions = "^3.3.1"
flake8-docstrings = "^1.5.0"
flake8-string-format = "^0.3.0"
pep8-naming = "^0.11.1"

[tool.poetry.plugins."mkdocs.plugins"]
mkdocstrings = "mkdocstrings.plugin:MkdocstringsPlugin"
@@ -99,32 +104,7 @@ exclude = ["tests/fixtures"]
"-R0913", # too many methods
"-R0914", # too many local variables
"-R0915", # too many statements
"-W0212", # redundant with WPS437 (access to protected attribute)
"-W0611", # redundant with F401 (unused import)
"-W1203", # lazy formatting for logging calls
"-VNE001", # short name
"-WPS305", # f-strings
"-WPS110", # common variable names (too annoying)
"-WPS125", # redundant with W0622 (builtin override), which is more precise about line number
"-WPS201", # too many imports
"-WPS202", # too many module members
"-WPS204", # overused expression
"-WPS210", # too many local variables
"-WPS211", # too many arguments
"-WPS213", # too many expressions
"-WPS214", # too many methods
"-WPS220", # too deep nesting
"-WPS223", # too many elif branches
"-WPS226", # string over-use: can't disable it per file?
"-WPS230", # too many public instance attributes
"-WPS306", # too cumbersome, asks to write class A(object)
"-WPS317", # multi-line paramaters (incompatible with Black)
"-WPS322", # multi-line strings (incompatible with attributes docstrings)
"-WPS326", # implicit string concatenation
"-WPS336", # explicit string concatenation
"-WPS402", # noqa overuse
"-WPS412", # __init__ modules with logic
"-WPS428", # statement with no effect (not compatible with attribute docstrings)
"-WPS433", # redundant with C0415 (not top-level import)
"-WPS529", # implicit dict.get usage (generally false-positive)
]
@@ -143,7 +143,7 @@ def do_convert_markdown(md: Markdown, text: str, heading_level: int, html_id: st
"""
md.treeprocessors["mkdocstrings_headings"].shift_by = heading_level
md.treeprocessors["mkdocstrings_ids"].id_prefix = html_id and html_id + "--"
try: # noqa: WPS501 (no except)
try:
return Markup(md.convert(text))
finally:
md.treeprocessors["mkdocstrings_headings"].shift_by = 0
@@ -387,7 +387,7 @@ def __init__(self, md, id_prefix: str):
super().__init__(md)
self.id_prefix = id_prefix

def run(self, root: Element): # noqa: WPS231 (not complex)
def run(self, root: Element):
if not self.id_prefix:
return
for el in root.iter():
@@ -76,8 +76,8 @@ def get_template_logger_function(logger_func: Callable) -> Callable:
A function.
"""

@contextfunction # noqa: WPS430 (nested function)
def wrapper(context: Context, msg: Optional[str] = None) -> str: # noqa: WPS430
@contextfunction
def wrapper(context: Context, msg: Optional[str] = None) -> str:
"""
Log a message.
@@ -125,7 +125,7 @@ def on_serve(self, server: Server, builder: Callable = None, **kwargs) -> Server
if builder is None:
# The builder parameter was added in mkdocs v1.1.1.
# See issue https://github.com/mkdocs/mkdocs/issues/1952.
builder = list(server.watcher._tasks.values())[0]["func"] # noqa: WPS437 (protected attribute)
builder = list(server.watcher._tasks.values())[0]["func"] # noqa: W0212 (protected member)
for element in self.config["watch"]:
log.debug(f"Adding directory '{element}' to watcher")
server.watch(element, builder)
@@ -25,7 +25,7 @@ def __init__(self, *args, **kwargs): # noqa: D107
# Code based on
# https://github.com/Python-Markdown/markdown/blob/8e7528fa5c98bf4652deb13206d6e6241d61630b/markdown/inlinepatterns.py#L780

def handleMatch(self, m, data) -> Union[Element, EvalIDType]: # noqa: WPS111,N802 (parent's casing)
def handleMatch(self, m, data) -> Union[Element, EvalIDType]: # noqa: N802 (parent's casing)
"""
Handle an element that matched.
@@ -67,7 +67,7 @@ def evalId(self, data: str, index: int, text: str) -> EvalIDType: # noqa: N802
Returns:
A tuple containing the identifier, its end position, and whether it matched.
"""
m = self.RE_LINK.match(data, pos=index) # noqa: WPS111
m = self.RE_LINK.match(data, pos=index)
if not m:
return None, index, False
identifier = m.group(1) or text
@@ -113,12 +113,12 @@ def relative_url(url_a: str, url_b: str) -> str:

# go up as many times as remaining a parts' depth
levels = len(parts_a) - 1
parts_relative = [".."] * levels + parts_b # noqa: WPS435 (list multiply ok)
parts_relative = [".."] * levels + parts_b
relative = "/".join(parts_relative)
return f"{relative}#{anchor}"


def fix_ref(url_map: Dict[str, str], from_url: str, unmapped: List[str]) -> Callable: # noqa: WPS231 (not that complex)
def fix_ref(url_map: Dict[str, str], from_url: str, unmapped: List[str]) -> Callable:
"""
Return a `repl` function for [`re.sub`](https://docs.python.org/3/library/re.html#re.sub).
@@ -138,7 +138,7 @@ def fix_ref(url_map: Dict[str, str], from_url: str, unmapped: List[str]) -> Call
and returning the replacement strings.
"""

def inner(match: Match): # noqa: WPS430 (nested function, no other way than side-effecting the warnings)
def inner(match: Match):
identifier = match["identifier"]
title = match["title"]

0 comments on commit 3ee6bf1

Please sign in to comment.