Skip to content
Open
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
31 changes: 23 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: no-commit-to-branch
- id: check-added-large-files
args: ["--maxkb=1000"]
- id: check-ast
Expand Down Expand Up @@ -46,7 +47,7 @@ repos:
rev: 1.16.0
hooks:
- id: blacken-docs
additional_dependencies: [black==22.3.0]
additional_dependencies: [black==24.4.2]

- repo: https://github.com/pycqa/flake8
rev: 7.0.0
Expand All @@ -59,6 +60,8 @@ repos:
flake8-builtins,
flake8-quotes>=3.3.2,
flake8-comprehensions,
flake8-bandit,
flake8-pydocstyle,
pandas-vet,
flake8-print,
pep8-naming,
Expand All @@ -84,12 +87,13 @@ repos:
- id: pydocstyle
additional_dependencies: [".[toml]"]

- repo: https://github.com/PyCQA/bandit
rev: 1.7.8
hooks:
- id: bandit
args: ["-c", "pyproject.toml"]
additional_dependencies: ["bandit[toml]"]
# Now using ruff and plug-in for flake8
# - repo: https://github.com/PyCQA/bandit
# rev: 1.7.8
# hooks:
# - id: bandit
# args: ["-c", "pyproject.toml"]
# additional_dependencies: ["bandit[toml]"]

- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
Expand All @@ -115,7 +119,18 @@ repos:
rev: v1.5.0
hooks:
- id: yesqa
additional_dependencies: ["flake8-builtins"]
additional_dependencies: [
flake8-bugbear,
flake8-builtins,
flake8-quotes>=3.3.2,
flake8-comprehensions,
flake8-bandit,
flake8-pydocstyle,
pandas-vet,
flake8-print,
pep8-naming,
doc8,
]

- repo: https://github.com/asottile/pyupgrade
rev: v3.15.2
Expand Down
4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
# Cython files. Hence, we do not add the source code path to the system path.
env_rtd = os.environ.get("READTHEDOCS")
# Check if on Read the docs
if not env_rtd == "True":
if env_rtd != "True":
print("Not on ReadTheDocs")
sys.path.insert(0, os.path.abspath("../.."))
else:
Expand Down Expand Up @@ -186,7 +186,7 @@ def find_source(): # numpydoc ignore=RT01
},
{
"name": "Slack",
"url": f"https://join.slack.com/t/{org}/shared_invite/zt-21ezi33ip-WGJCUBCWc5yVrr6FOsARaw", # noqa: E501
"url": f"https://join.slack.com/t/{org}/shared_invite/zt-21ezi33ip-WGJCUBCWc5yVrr6FOsARaw",
"icon": "fab fa-slack",
},
{
Expand Down
6 changes: 3 additions & 3 deletions predictably/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@

__author__: List[str] = ["RNKuhns"]
__all__: List[str] = [
"get_default_config",
"config_context",
"get_config",
"set_config",
"get_default_config",
"reset_config",
"config_context",
"set_config",
]
6 changes: 3 additions & 3 deletions predictably/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@

__author__: List[str] = ["RNKuhns"]
__all__: List[str] = [
"get_default_config",
"config_context",
"get_config",
"set_config",
"get_default_config",
"reset_config",
"config_context",
"set_config",
]


Expand Down
6 changes: 3 additions & 3 deletions predictably/_config_param_setting.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ def is_valid_param_value(self, value: Any) -> bool:
Whether a parameter value is valid.
"""
valid_param: bool
if not isinstance(value, self.expected_type):
valid_param = False
elif self.allowed_values is not None and value not in self.get_allowed_values():
if not isinstance(value, self.expected_type) or (
self.allowed_values is not None and value not in self.get_allowed_values()
):
valid_param = False
else:
valid_param = True
Expand Down
2 changes: 1 addition & 1 deletion predictably/_core/_pprint/_pprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def __init__(
# (they are treated as dicts)
self.n_max_elements_to_show = n_max_elements_to_show

def format(self, obj, context, maxlevels, level): # noqa: A003
def format(self, obj, context, maxlevels, level):
return _safe_repr(
obj, context, maxlevels, level, changed_only=self.changed_only
)
Expand Down
56 changes: 28 additions & 28 deletions predictably/_core/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,6 @@
__author__ = ["RNKuhns"]

__all__ = [
"test_get_class_tags",
"test_get_class_tag",
"test_get_tags",
"test_get_tag",
"test_get_tag_raises",
"test_set_tags",
"test_set_tags_works_with_missing_tags_dynamic_attribute",
"test_clone_tags",
"test_is_composite",
"test_components",
"test_components_raises_error_base_class_is_not_class",
"test_components_raises_error_base_class_is_not_baseobject_subclass",
"test_reset",
"test_reset_composite",
"test_get_init_signature",
"test_get_init_signature_raises_error_for_invalid_signature",
"test_get_param_names",
"test_get_params",
"test_get_params_invariance",
"test_get_params_after_set_params",
"test_set_params",
"test_set_params_raises_error_non_existent_param",
"test_set_params_raises_error_non_interface_composite",
"test_raises_on_get_params_for_param_arg_not_assigned_to_attribute",
"test_set_params_with_no_param_to_set_returns_object",
# "test_clone",
# "test_clone_2",
# "test_clone_raises_error_for_nonconforming_objects",
Expand All @@ -59,15 +34,40 @@
# "test_clone_class_rather_than_instance_raises_error",
# "test_clone_sklearn_composite",
"test_baseobject_repr",
"test_baseobject_str",
"test_baseobject_repr_mimebundle_",
"test_repr_html_wraps",
"test_baseobject_str",
"test_clone_tags",
"test_components",
"test_components_raises_error_base_class_is_not_baseobject_subclass",
"test_components_raises_error_base_class_is_not_class",
# "test_get_test_params",
# "test_get_test_params_raises_error_when_params_required",
# "test_create_test_instance",
# "test_create_test_instances_and_names",
# "test_has_implementation_of",
"test_eq_dunder",
"test_get_class_tag",
"test_get_class_tags",
"test_get_init_signature",
"test_get_init_signature_raises_error_for_invalid_signature",
"test_get_param_names",
"test_get_params",
"test_get_params_after_set_params",
"test_get_params_invariance",
"test_get_tag",
"test_get_tag_raises",
"test_get_tags",
"test_is_composite",
"test_raises_on_get_params_for_param_arg_not_assigned_to_attribute",
"test_repr_html_wraps",
"test_reset",
"test_reset_composite",
"test_set_params",
"test_set_params_raises_error_non_existent_param",
"test_set_params_raises_error_non_interface_composite",
"test_set_params_with_no_param_to_set_returns_object",
"test_set_tags",
"test_set_tags_works_with_missing_tags_dynamic_attribute",
]

import inspect
Expand Down Expand Up @@ -984,7 +984,7 @@ def test_baseobject_repr(
long_base_obj_repr = fixture_class_parent(a=["long_params"] * 1000)
assert len(repr(long_base_obj_repr)) == 535

named_objs = [(f"Step {i+1}", Child()) for i in range(25)]
named_objs = [(f"Step {i + 1}", Child()) for i in range(25)]
base_comp = CompositionDummy(foo=Parent(c=Child(c=named_objs)))
assert len(repr(base_comp)) == 1362

Expand Down
1 change: 0 additions & 1 deletion predictably/_core/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,6 @@ def test_config_threadsafe():
between threads. Same test as `test_config_threadsafe_joblib` but with
`ThreadPoolExecutor`.
"""

print_changed_only_vals = [False, True, False, True]
sleep_durations = [0.1, 0.2, 0.1, 0.2]

Expand Down
2 changes: 1 addition & 1 deletion predictably/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from predictably._core._base import BaseEstimator, BaseObject

__all__: List[str] = ["Parent", "Child"]
__all__: List[str] = ["Child", "Parent"]
__author__: List[str] = ["RNKuhns"]

PREDICTABLY_BASE_CLASSES = (BaseObject, BaseEstimator)
Expand Down
1 change: 0 additions & 1 deletion predictably/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,6 @@ def test_config_threadsafe():
between threads. Same test as `test_config_threadsafe_joblib` but with
`ThreadPoolExecutor`.
"""

print_changed_only_vals = [False, True, False, True]
sleep_durations = [0.1, 0.2, 0.1, 0.2]

Expand Down
4 changes: 2 additions & 2 deletions predictably/utils/_iter.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

__author__: List[str] = ["RNKuhns"]
__all__: List[str] = [
"_scalar_to_seq",
"_format_seq_to_str",
"_remove_single",
"_remove_type_text",
"_format_seq_to_str",
"_scalar_to_seq",
]


Expand Down
51 changes: 49 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ linters = [
"flake8-builtins",
"flake8-quotes",
"flake8-comprehensions",
"flake8-bandit",
"flake8-pydocstyle",
"pandas-vet",
"flake8-print",
"pep8-naming",
Expand Down Expand Up @@ -115,14 +117,59 @@ addopts = [
profile = "black"
src_paths = ["predictably/*"]
multi_line_output = 3
known_first_party = ["predictably"]
known_first_party = ["predictably", "predictably-core"]

[tool.black]
line-length = 88

[tool.pydocstyle]
convention = "numpy"

[tool.ruff]
line-length = 88
indent-width = 4

[tool.ruff.lint]
select = [
"E",
"F",
"I",
"B",
"N",
"A",
"D",
"Q",
"UP",
"SIM",
"W",
"S",
"C4",
"T20",
"PTH",
"RUF",
]
ignore = ["D413", "W191"]
unfixable = ["B"]
preview = true

[tool.ruff.lint.per-file-ignores]
"**/tests/*.py" = ["S101"]

[tool.ruff.format]
# Setup to format like black
quote-style = "double"
indent-style = "space"
skip-magic-trailing-comma = false
line-ending = "auto"

docstring-code-line-length = "dynamic"

[tool.ruff.lint.pydocstyle]
convention = "numpy"

[tool.ruff.lint.flake8-quotes]
docstring-quotes = "double"

[tool.coverage.report]
show_missing = true
ignore_errors = true
Expand All @@ -144,7 +191,7 @@ ignore = ["D004"]
ignore_path = ["docs/_build", "docs/source/api_reference/auto_generated"]

[tool.bandit]
exclude_dirs = ["*/tests/*", "*/testing/*"]
exclude_dirs = ["**/tests/*", "**/testing/*"]

[tool.numpydoc_validation]
checks = ["all", "GL01", "SA01", "EX01"]
Expand Down
10 changes: 10 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ inline-quotes = double
extend-ignore = E203
extend-select = B904, B907
exclude = .git, __pycache__, docs/source/conf.py, build, dist
require-plugins =
flake8-bugbear,
flake8-builtins,
flake8-quotes,
flake8-bandit,
flake8-pydocstyle,
flake8-comprehensions,
pandas-vet,
flake8-print,
pep8-naming

[mypy]
ignore_missing_imports = True