Skip to content

Commit e3ab34d

Browse files
committed
plac8 flake8-bugbear
1 parent 7f87b73 commit e3ab34d

6 files changed

Lines changed: 23 additions & 18 deletions

File tree

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
repos:
22
- repo: https://github.com/psf/black
3-
rev: 22.8.0
3+
rev: 26.1.0
44
hooks:
55
- id: black
66
language_version: python3.11
77
- repo: https://github.com/PyCQA/flake8
8-
rev: 5.0.4
8+
rev: 7.3.0
99
hooks:
1010
- id: flake8
11-
additional_dependencies: ["flake8-bugbear==22.8.23"]
11+
additional_dependencies: ["flake8-bugbear==25.11.29"]
1212
- repo: https://github.com/asottile/blacken-docs
1313
rev: v1.12.1
1414
hooks:
1515
- id: blacken-docs
16-
additional_dependencies: [black==22.8.0]
16+
additional_dependencies: [black==26.1.0]

elasticsearch_metrics/djelmetrics_imps.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,24 @@ def each_djelmetrics_imp() -> Iterator[ProtoDjelmetricsImp]:
2424
def get_djelmetrics_imp(imp_name: str) -> ProtoDjelmetricsImp:
2525
try:
2626
_raw_imp_config = settings.DJELMETRICS_IMPS[imp_name]
27-
except KeyError:
28-
raise ValueError(f"{imp_name!r} not found in `settings.DJELMETRICS_IMPS`")
27+
except KeyError as _error:
28+
raise ValueError(
29+
f"{imp_name!r} not found in `settings.DJELMETRICS_IMPS`"
30+
) from _error
2931
try:
3032
_imp_path = _raw_imp_config["DJELMETRICS_IMP"]
31-
except KeyError:
33+
except KeyError as _error:
3234
raise ValueError(
3335
f"missing 'DJELMETRICS_IMP' from {imp_name!r} in `settings.DJELMETRICS_IMPS`"
3436
" -- must be a path to a djelme imp module like those under"
3537
"`elasticsearch_metrics.imps...`"
36-
)
38+
) from _error
3739
try:
3840
_imp_module = importlib.import_module(_imp_path)
39-
except ImportError:
41+
except ImportError as _error:
4042
raise ValueError(
4143
f"could not import {_imp_path!r} for `settings.DJELMETRICS_IMPS[{imp_name!r}]`"
42-
)
44+
) from _error
4345
assert isinstance(_imp_module, ProtoDjelmetricsImpModule)
4446
_imp_config = {
4547
_k: _v for _k, _v in _raw_imp_config.items() if _k != "DJELMETRICS_IMP"

elasticsearch_metrics/exceptions.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ class ElasticsearchMetricsError(Exception):
55
class IndexTemplateNotFoundError(ElasticsearchMetricsError):
66
def __init__(self, message, client_error):
77
self.client_error = client_error
8-
super(IndexTemplateNotFoundError, self).__init__(message)
8+
super(IndexTemplateNotFoundError, self).__init__(message, client_error)
99

1010

1111
class IndexTemplateOutOfSyncError(ElasticsearchMetricsError):
1212
def __init__(self, message, mappings_in_sync, patterns_in_sync, settings_in_sync):
1313
self.mappings_in_sync = mappings_in_sync
1414
self.patterns_in_sync = patterns_in_sync
1515
self.settings_in_sync = settings_in_sync
16-
super(IndexTemplateOutOfSyncError, self).__init__(message)
16+
super(IndexTemplateOutOfSyncError, self).__init__(
17+
message, mappings_in_sync, patterns_in_sync, settings_in_sync
18+
)

elasticsearch_metrics/field.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ class Date(edsl_field.Date):
2525

2626
def __init__(self, default_timezone=None, *args, **kwargs):
2727
default_timezone = default_timezone or getattr(settings, "TIMEZONE", None)
28-
super(Date, self).__init__(default_timezone=default_timezone, *args, **kwargs)
28+
super(Date, self).__init__(*args, default_timezone=default_timezone, **kwargs)

elasticsearch_metrics/tests/_test_util.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99

1010

1111
class SimpleDjelmeTestCase(SimpleTestCase):
12-
"""SimpleDjelmeTestCase: base test case with djelme-specific conveniences
13-
"""
12+
"""SimpleDjelmeTestCase: base test case with djelme-specific conveniences"""
1413

1514
def enterContext(self, context_manager):
1615
# TestCase.enterContext added in python3.11 -- implementing here until 3.10 eol
@@ -39,8 +38,8 @@ def run_mgmt_command(
3938

4039

4140
class RealElasticTestCase(SimpleDjelmeTestCase):
42-
"""RealElasticTestCase: base test case with actual elasticsearch running
43-
"""
41+
"""RealElasticTestCase: base test case with actual elasticsearch running"""
42+
4443
__auto_setup_imps: bool
4544

4645
def __init_subclass__(cls, /, auto_setup_imps: bool = True, **kwargs):

elasticsearch_metrics/tests/test_management_commands/test_sync_metrics.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ def test_with_connection(self):
3939
"default": {"hosts": "localhost:9201"},
4040
"alternate": {"hosts": "localhost:9202"},
4141
}
42-
out, err = self.run_mgmt_command(sync_metrics.Command, "--connection", "alternate")
42+
out, err = self.run_mgmt_command(
43+
sync_metrics.Command, "--connection", "alternate"
44+
)
4345
call_kwargs = self.mock_sync_index_template.call_args[1]
4446
assert call_kwargs["using"] == "alternate"
4547
assert "Using connection: 'alternate'" in out

0 commit comments

Comments
 (0)