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 types, config for mypy #52

Merged
merged 1 commit into from
Jul 13, 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
13 changes: 5 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,16 @@ repos:
description: Check for files with names that would conflict on case-insensitive filesystems like MacOS/Windows.
- id: no-commit-to-branch
description: Protect specific branches from direct checkins.
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.0.263'
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.1
hooks:
- id: ruff
args: [ --fix ]
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.950
rev: v1.10.1
hooks:
- id: mypy
- repo: https://github.com/ambv/black
rev: 22.6.0
hooks:
- id: black
args: [--preview]
- repo: local
hooks:
- id: unittest
Expand Down
12 changes: 0 additions & 12 deletions mypy.ini

This file was deleted.

10 changes: 8 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,11 @@ requires = ["setuptools >= 40.6.0", "wheel"]
build-backend = "setuptools.build_meta"

[tool.ruff]
select = ["E", "F", "B", "I001", "I002"]
target-version = "py38"
target-version = "py311"

[[tool.mypy.overrides]]
module = [
"tqdm.*",
"ahocorasick.*",
]
ignore_missing_imports = true
1 change: 1 addition & 0 deletions reach/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""A package for reading and manipulating word embeddings."""

from reach.reach import Reach, normalize

try:
Expand Down
9 changes: 4 additions & 5 deletions reach/autoreach.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import re
from string import punctuation
from typing import Hashable, List, Optional, Union

try:
from ahocorasick import Automaton
Expand Down Expand Up @@ -59,10 +58,10 @@ class AutoReach(Reach):
def __init__(
self,
vectors: Matrix,
items: List[Hashable],
lowercase: Union[str, bool] = "auto",
items: list[str],
lowercase: str | bool = "auto",
name: str = "",
unk_index: Optional[int] = None,
unk_index: int | None = None,
) -> None:
"""Initialize a Reach instance with an array and list of strings."""
super().__init__(vectors, items, name, unk_index)
Expand Down Expand Up @@ -96,7 +95,7 @@ def is_valid_token(self, token: str, tokens: str, end_index: int) -> bool:

return True

def bow(self, tokens: Tokens, remove_oov: bool = True) -> List[int]:
def bow(self, tokens: Tokens, remove_oov: bool = True) -> list[int]:
"""
Create a bow representation from a string.

Expand Down
Loading
Loading