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

Add a few dotfiles to improve newcomers' experience #1368

Merged
merged 1 commit into from
Feb 5, 2025
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
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# EditorConfig is awesome: https://EditorConfig.org
yvan-sraka marked this conversation as resolved.
Show resolved Hide resolved

# top-most EditorConfig file
root = true

[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.yaml]
indent_size = 2
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,3 @@ benchmarks/results
build
docs/build
logs
logs/
__pycache__/
27 changes: 7 additions & 20 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,33 +1,20 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v5.0.0
hooks:
- id: check-merge-conflict
- id: debug-statements
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
args: [--profile, black]
- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
hooks:
- id: pyupgrade
args: [--py37-plus]
- repo: https://github.com/pycqa/flake8
rev: 6.0.0
hooks:
- id: flake8
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.2.0
rev: v1.14.1
hooks:
- id: mypy
args: [--allow-redefinition]
exclude: ^examples/
additional_dependencies: [types-tqdm, types-Pillow]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.9.1
hooks:
- id: ruff
args: ["--config=pyproject.toml"]
2 changes: 2 additions & 0 deletions .pydocstyle
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[pydocstyle]
convention = numpy
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"python.testing.pytestArgs": [
"tests"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}
6 changes: 3 additions & 3 deletions outlines/fsm/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,19 @@ def enum_format_fn(sequence: str) -> str:

return enum_regex_str, enum_format_fn

if python_type == float:
if python_type is float:

def float_format_fn(sequence: str) -> float:
return float(sequence)

return FLOAT, float_format_fn
elif python_type == int:
elif python_type is int:

def int_format_fn(sequence: str) -> int:
return int(sequence)

return INTEGER, int_format_fn
elif python_type == bool:
elif python_type is bool:

def bool_format_fn(sequence: str) -> bool:
return bool(sequence)
Expand Down
4 changes: 2 additions & 2 deletions outlines/processors/base_logits_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ def _from_torch(tensor: torch.Tensor, target_type: Type) -> Array:
elif target_type == np.ndarray:
return tensor.detach().numpy()

elif target_type == list:
elif target_type is list:
return tensor.detach().tolist()

elif target_type == tuple:
elif target_type is tuple:
return tuple(tensor.detach().tolist())

elif is_mlx_array_type(target_type):
Expand Down
7 changes: 7 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -174,3 +174,10 @@ show_missing = true
[tool.diff_cover]
compare_branch = "origin/main"
diff_range_notation = ".."

[tool.docformatter]
style = "numpy"
in-place = true

[tool.ruff.lint]
ignore = [ "E731", "F401" ]
Loading