Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix and enable Ruff lints PYI002, PYI026 #496

Merged
merged 4 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,9 @@ ignore = ["PYI021", "PYI024", "PYI041", "PYI043"]
"F405",
"F822",
"F821",
"PYI026", # TODO fix these errors
"PGH003", # TODO fix these errors
"PYI002", # TODO fix these errors
]
"rest_framework-stubs/compat.pyi" = ["PYI042"]

[tool.ruff.flake8-tidy-imports.banned-api]
"_typeshed.Self".msg = "Use typing_extensions.Self (PEP 673) instead."
Expand Down
28 changes: 14 additions & 14 deletions rest_framework-stubs/compat.pyi
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
from typing import Any

from django.db.models import QuerySet
from typing_extensions import TypeAlias

try:
from django.contrib.postgres import fields as postgres_fields
except ImportError:
postgres_fields = None # type: ignore
postgres_fields: TypeAlias = None # type: ignore[no-redef]
try:
import coreapi
except ImportError:
coreapi = None
coreapi: TypeAlias = None # type: ignore[no-redef]
try:
import uritemplate
except ImportError:
uritemplate = None # type: ignore
uritemplate: TypeAlias = None # type: ignore[no-redef]
try:
import coreschema
except ImportError:
coreschema = None
coreschema: TypeAlias = None # type: ignore[no-redef]
try:
import yaml
except ImportError:
yaml = None # type: ignore
yaml: TypeAlias = None # type: ignore[no-redef]
try:
import requests
except ImportError:
requests = None # type: ignore
requests: TypeAlias = None # type: ignore[no-redef]
try:
import pygments
except ImportError:
pygments = None
pygments: TypeAlias = None # type: ignore[no-redef]

try:
import markdown
def apply_markdown(text: str) -> str: ...

except ImportError:
apply_markdown = None # type: ignore
markdown = None # type: ignore

if markdown is not None and pygments is not None:
from markdown.preprocessors import Preprocessor
def apply_markdown(text: str) -> str: ...

class CodeBlockPreprocessor(Preprocessor):
pattern: Any
formatter: Any
def run(self, lines: list[str]) -> list[str]: ...

except ImportError:
apply_markdown: TypeAlias = None # type: ignore[no-redef]
markdown: TypeAlias = None # type: ignore[no-redef]

def pygments_css(style: Any) -> str | None: ...
def pygments_highlight(text: str, lang: str, style: Any) -> Any: ...
def md_filter_add_syntax_highlight(md: Any) -> bool: ...
Expand Down