Skip to content
This repository has been archived by the owner on Jan 5, 2024. It is now read-only.

Commit

Permalink
🏭 Standardize.
Browse files Browse the repository at this point in the history
Callables (lower case) imported must be qualified. Classes (upper case) imported must not be qualified.
  • Loading branch information
rentruewang committed Nov 14, 2023
1 parent a17abc9 commit b60d94c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions perbert/data/collators.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from abc import abstractmethod
import abc
from typing import Any, Dict, List, Protocol, Type

from transformers import DataCollatorForLanguageModeling, DataCollatorForWholeWordMask
Expand All @@ -9,7 +9,7 @@


class Collator(Protocol):
@abstractmethod
@abc.abstractmethod
def __call__(self, encodings: List[Dict[str, Any]]) -> Dict[str, Any]:
...

Expand Down
14 changes: 7 additions & 7 deletions perbert/data/datasets/mappers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from abc import abstractmethod
import abc
from typing import Any, Callable, Dict, List, Protocol, TypeVar

import loguru
Expand All @@ -12,7 +12,7 @@


class Mappable(Protocol):
@abstractmethod
@abc.abstractmethod
def filter(
self,
function: Callable[[Any], Any],
Expand All @@ -26,7 +26,7 @@ def filter(
) -> Self:
...

@abstractmethod
@abc.abstractmethod
def map(
self,
function: Callable[[Any], Any],
Expand All @@ -42,11 +42,11 @@ def map(
...

@property
@abstractmethod
@abc.abstractmethod
def column_names(self) -> List[str] | Dict[str, List[str]]:
...

@abstractmethod
@abc.abstractmethod
def remove_columns(self, column_names: str | List[str]) -> Self:
...

Expand All @@ -68,11 +68,11 @@ def _flat_column_names(mapper: Mappable) -> List[str]:


class Mapper(Protocol[T]):
@abstractmethod
@abc.abstractmethod
def __init__(self, cfg: DictConfig, mapper: T) -> None:
...

@abstractmethod
@abc.abstractmethod
def apply(self) -> T:
...

Expand Down
6 changes: 3 additions & 3 deletions perbert/data/datasets/wrappers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from abc import abstractmethod
import abc
from typing import Dict, Generic, Protocol, Sized, TypeVar

import loguru
Expand All @@ -22,12 +22,12 @@
class Indexible(Protocol[K, V]):
"Indexible type implements both `__len__` and `__getitem__`"

@abstractmethod
@abc.abstractmethod
def __len__(self) -> int:
"self.__len__() <==> len(self)"
...

@abstractmethod
@abc.abstractmethod
def __getitem__(self, key: K) -> V:
"self.__getitem__(key) <==> self[key]"

Expand Down

0 comments on commit b60d94c

Please sign in to comment.