Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
Daverball committed Nov 21, 2023
1 parent a4ebe4f commit 322bbd7
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 14 deletions.
14 changes: 9 additions & 5 deletions stubs/fanstatic/fanstatic/compiler.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ from _typeshed import StrOrBytesPath
from abc import abstractmethod
from logging import Logger
from subprocess import Popen
from typing import Any, ClassVar
from typing import Any, ClassVar, NewType
from typing_extensions import Literal

import setuptools.command.sdist
Expand Down Expand Up @@ -53,8 +53,10 @@ class NullCompiler(Compiler):
@property
def available(self) -> Literal[False]: ...

SOURCE: object
TARGET: object
_SourceType = NewType("_SourceType", object)
_TargetType = NewType("_TargetType", object)
SOURCE: _SourceType
TARGET: _TargetType

class CommandlineBase:
@property
Expand All @@ -63,13 +65,15 @@ class CommandlineBase:
arguments: ClassVar[list[str]]
@property
def available(self) -> bool: ...
def process(self, source: StrOrBytesPath, target: StrOrBytesPath) -> Popen[str]: ...
def process(self, source: StrOrBytesPath | _SourceType, target: StrOrBytesPath | _TargetType) -> Popen[str]: ...

class CoffeeScript(CommandlineBase, Compiler):
name: ClassVar[Literal["coffee"]]
command: ClassVar[Literal["coffee"]]
source_extension = NotImplemented
def process(self, source: StrOrBytesPath, target: StrOrBytesPath) -> None: ... # type:ignore[override]
def process(
self, source: StrOrBytesPath | _SourceType, target: StrOrBytesPath | _TargetType
) -> None: ... # type:ignore[override]

COFFEE_COMPILER: CoffeeScript

Expand Down
13 changes: 8 additions & 5 deletions stubs/fanstatic/fanstatic/core.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ from abc import abstractmethod
from collections.abc import Callable, Iterable
from threading import local
from types import ModuleType
from typing import NewType
from typing_extensions import Literal, TypeAlias

from fanstatic.compiler import Compiler, Minifier
Expand Down Expand Up @@ -96,7 +97,8 @@ class Asset(Dependable):
def set_dependencies(self, depends: Iterable[Dependable] | None) -> None: ...
def list_assets(self) -> set[Asset]: ...

NOTHING: object
_NothingType = NewType("_NothingType", object)
NOTHING: _NothingType

class Resource(Renderable, Asset):
relpath: str
Expand All @@ -123,8 +125,8 @@ class Resource(Renderable, Asset):
debug: str | Resource | None = None,
dont_bundle: bool = False,
minified: str | Resource | None = None,
minifier: Minifier = ...,
compiler: Compiler = ...,
minifier: Minifier | _NothingType = ...,
compiler: Compiler | _NothingType = ...,
source: str | None = None,
mode_parent: str | None = None,
) -> None: ...
Expand All @@ -134,7 +136,8 @@ class Resource(Renderable, Asset):
def mode(self, mode: str | None) -> Resource: ...
def need(self, slots: dict[Slot, Resource] | None = None) -> None: ...

REQUIRED_DEFAULT_MARKER: object
_RequiredDefaultMarkerType = NewType("_RequiredDefaultMarkerType", object)
REQUIRED_DEFAULT_MARKER: _RequiredDefaultMarkerType

class Slot(Asset):
default: Resource | None
Expand All @@ -145,7 +148,7 @@ class Slot(Asset):
library: Library,
extension: str,
depends: Iterable[Dependable] | None = None,
required: bool = ...,
required: bool | _RequiredDefaultMarkerType = ...,
default: Resource | None = None,
) -> None: ...

Expand Down
6 changes: 3 additions & 3 deletions stubs/fanstatic/fanstatic/injector.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ from _typeshed.wsgi import StartResponse, WSGIApplication, WSGIEnvironment
from abc import abstractmethod
from collections.abc import Iterable
from typing import Any
from typing_extensions import Literal, TypedDict
from typing_extensions import Literal, TypedDict, Unpack

from fanstatic.core import Dependable, NeededResources, Resource
from fanstatic.inclusion import Inclusion
Expand Down Expand Up @@ -35,8 +35,8 @@ class Injector:
config: _NeededResourcesConfig
injector: InjectorPlugin
def __init__(
self, app: WSGIApplication, injector: InjectorPlugin | None = None, **config: Any
) -> None: ... # FIXME: Switch to Unpack[_NeededResourcesConfig]
self, app: WSGIApplication, injector: InjectorPlugin | None = None, **config: Unpack[_NeededResourcesConfig]
) -> None: ...
def __call__(self, environ: WSGIEnvironment, start_response: StartResponse) -> Iterable[bytes]: ...

class InjectorPlugin:
Expand Down
2 changes: 1 addition & 1 deletion stubs/fanstatic/fanstatic/publisher.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from _typeshed import StrOrBytesPath
from _typeshed.wsgi import StartResponse, WSGIApplication
from _typeshed.wsgi import StartResponse, WSGIApplication, WSGIEnvironment
from collections.abc import Iterable
from typing import IO, Any
from typing_extensions import Literal
Expand Down

0 comments on commit 322bbd7

Please sign in to comment.