Last active
May 5, 2023 16:58
-
-
Save cidrblock/ec3412bacfeb34dbc2d334c1d53bef83 to your computer and use it in GitHub Desktop.
Extract pylint rules implimented in ruff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from bs4 import BeautifulSoup | |
url = "https://github.com/charliermarsh/ruff/issues/970" | |
response = requests.get(url) | |
html_content = response.content | |
soup = BeautifulSoup(html_content, "html.parser") | |
li_tags = soup.find_all("li") | |
done = [] | |
for li in li_tags: | |
if "class" in li.attrs and "task-list-item" in li.attrs["class"]: | |
names = [child.name for child in li.children if child.name] | |
if "input" in names and "code" in names: | |
checked = [ | |
child.attrs.get("checked") | |
for child in li.children | |
if child.name and child.name == "input" and "checked" in child.attrs | |
] | |
if checked: | |
codes = [child.text for child in li.children if child.name == "code"] | |
done.append(tuple(codes)) | |
done.sort(key=lambda x: x[1]) | |
for entry in done: | |
name = entry[0] | |
pylint_code = entry[1] | |
if len(entry) == 3: | |
ruff_code = entry[2] | |
else: | |
ruff_code = f"PL{entry[1]}" | |
print(f' "{pylint_code}", # {name} / ruff {ruff_code}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment