Skip to content

Commit

Permalink
Add a few dotfiles to improve newcomers' experience (#1368)
Browse files Browse the repository at this point in the history
  • Loading branch information
yvan-sraka authored Feb 5, 2025
1 parent 437ffe4 commit 1842fe7
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 27 deletions.
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

# 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" ]

0 comments on commit 1842fe7

Please sign in to comment.