Skip to content

Commit

Permalink
Bump pre-commit repos, run through Black 24.1.1
Browse files Browse the repository at this point in the history
Black changes witnessed (mainly) include:
- addition of blank line between module docstrings and imports
- removal of blank lines between class declarations and docstrings
- prefer splitting assignment statements on right-hand side
- wrap conditional expressions that span multiple lines in parens
- put `...` in stubs on same line
- add E701 and E704 to flake8 ignore list, see:
    - https://github.com/psf/black/blob/main/docs/guides/using_black_with_other_tools.md#e701--e704
    - psf/black#3887 (E704)
    - psf/black#4173 (E701)
  • Loading branch information
JonathanWillitts committed Feb 2, 2024
1 parent 060dd0c commit 60fe737
Show file tree
Hide file tree
Showing 20 changed files with 23 additions and 54 deletions.
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Expand Up @@ -3,32 +3,32 @@ exclude: tests/etc/user-*

repos:
- repo: https://github.com/PyCQA/bandit
rev: 1.7.5
rev: 1.7.7
hooks:
- id: bandit
args:
- "-x *test*.py"

- repo: https://github.com/psf/black
rev: 23.9.1
rev: 24.1.1
hooks:
- id: black
language_version: python3.10

- repo: https://github.com/pycqa/flake8
rev: 6.1.0
rev: 7.0.0
hooks:
- id: flake8
args:
- "--config=setup.cfg"

- repo: https://github.com/PyCQA/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: requirements-txt-fixer
files: requirements/.*\.txt$
Expand All @@ -43,7 +43,7 @@ repos:
- id: check-toml

- repo: https://github.com/adrienverge/yamllint
rev: v1.32.0
rev: v1.33.0
hooks:
- id: yamllint
args:
Expand Down
1 change: 0 additions & 1 deletion edc_metadata/metadata/metadata_getter.py
Expand Up @@ -82,7 +82,6 @@ def model_cls_registered_with_admin_site(model_cls: Any) -> bool:


class MetadataGetter:

"""A class that gets a filtered queryset of metadata --
`metadata_objects`.
Expand Down
1 change: 0 additions & 1 deletion edc_metadata/metadata_handler.py
Expand Up @@ -29,7 +29,6 @@ class MetadataObjectDoesNotExist(Exception):


class MetadataHandler:

"""A class to get or create a CRF metadata model instance."""

creator_cls = Creator
Expand Down
3 changes: 1 addition & 2 deletions edc_metadata/metadata_helper/metadata_helper_mixin.py
Expand Up @@ -12,8 +12,7 @@
from ..models import CrfMetadata, RequisitionMetadata
else:

class VisitScheduleFieldsProtocol:
...
class VisitScheduleFieldsProtocol: ...


class MetadataHelperMixin(VisitScheduleFieldsProtocol):
Expand Down
1 change: 0 additions & 1 deletion edc_metadata/metadata_inspector.py
Expand Up @@ -3,7 +3,6 @@


class MetaDataInspector:

"""Inspects for the given timepoint and form."""

metadata_model_cls = CrfMetadata
Expand Down
1 change: 0 additions & 1 deletion edc_metadata/metadata_rules/logic.py
Expand Up @@ -19,7 +19,6 @@ class RuleLogicError(Exception):


class Logic:

"""A class that serves as a container for the logic attribute
of a rule, the predicate, and the outcomes (result) of that
rule; consequence and alternative.
Expand Down
1 change: 0 additions & 1 deletion edc_metadata/metadata_rules/metadata_rule_evaluator.py
Expand Up @@ -11,7 +11,6 @@


class MetadataRuleEvaluator:

"""Main class to evaluate rules.
Used by model mixin.
Expand Down
1 change: 0 additions & 1 deletion edc_metadata/metadata_rules/predicate.py
Expand Up @@ -52,7 +52,6 @@ def get_value(attr: str = None, source_model: str | None = None, **kwargs) -> An


class P(BasePredicate):

"""
Simple predicate class.
Expand Down
1 change: 0 additions & 1 deletion edc_metadata/metadata_rules/rule_evaluator.py
Expand Up @@ -31,7 +31,6 @@ class RuleEvaluatorRegisterSubjectError(Exception):


class RuleEvaluator:

"""A class to evaluate a rule.
Sets `self.result` to REQUIRED, NOT_REQUIRED or None.
Expand Down
1 change: 0 additions & 1 deletion edc_metadata/metadata_rules/rule_group.py
Expand Up @@ -16,7 +16,6 @@ class TargetModelConflict(Exception):


class RuleGroup:

"""Base class for CRF and Requisition rule groups."""

@classmethod
Expand Down
1 change: 0 additions & 1 deletion edc_metadata/metadata_rules/site.py
Expand Up @@ -18,7 +18,6 @@ class SiteMetadataNoRulesError(Exception):


class SiteMetadataRules:

"""Main controller of :class:`MetadataRules` objects."""

def __init__(self) -> None:
Expand Down
1 change: 0 additions & 1 deletion edc_metadata/metadata_wrappers/metadata_wrapper.py
Expand Up @@ -17,7 +17,6 @@ class MetadataWrapperError(Exception):


class MetadataWrapper:

"""A class that wraps the corresponding model instance, or not, for the
given metadata object and sets it to itself along with other
attributes like the visit, model class, metadata_obj, etc.
Expand Down
1 change: 0 additions & 1 deletion edc_metadata/metadata_wrappers/metadata_wrappers.py
Expand Up @@ -9,7 +9,6 @@


class MetadataWrappers:

"""A class that generates a collection of MetadataWrapper objects, e.g. CRF
or REQUISITION, from a queryset of metadata objects.
Expand Down
Expand Up @@ -19,8 +19,7 @@
from edc_visit_tracking.typing_stubs import RelatedVisitProtocol
else:

class RelatedVisitProtocol:
...
class RelatedVisitProtocol: ...


class CreatesMetadataModelMixin(RelatedVisitProtocol, models.Model):
Expand Down
1 change: 0 additions & 1 deletion edc_metadata/models/crf_metadata_model_mixin.py
Expand Up @@ -27,7 +27,6 @@ class CrfMetadataModelMixin(
VisitScheduleFieldsModelMixin,
models.Model,
):

"""Mixin for CrfMetadata and RequisitionMetadata models."""

visit_code = models.CharField(max_length=25)
Expand Down
1 change: 0 additions & 1 deletion edc_metadata/requisition/requisition_metadata_handler.py
Expand Up @@ -13,7 +13,6 @@


class RequisitionMetadataHandler(MetadataHandler):

"""A class to get or create a requisition metadata
model instance.
"""
Expand Down
1 change: 0 additions & 1 deletion edc_metadata/requisition/requisition_metadata_updater.py
Expand Up @@ -15,7 +15,6 @@ class RequisitionMetadataError(Exception):


class RequisitionMetadataUpdater(MetadataUpdater):

"""A class to update a subject's requisition metadata given
the visit, target model name, panel and desired entry status.
"""
Expand Down
42 changes: 14 additions & 28 deletions edc_metadata/stubs.py
Expand Up @@ -27,8 +27,7 @@ class VisitModel(Protocol):
visit_schedule_name: str
_meta: ModelMetaStub

def visit_schedule(self) -> VisitSchedule:
...
def visit_schedule(self) -> VisitSchedule: ...


class CrfMetadataModelStub(Protocol):
Expand All @@ -45,17 +44,13 @@ class CrfMetadataModelStub(Protocol):
visit: VisitModel
_meta: ModelMetaStub

def save(self, *args, **kwargs) -> None:
...
def save(self, *args, **kwargs) -> None: ...

def delete(self) -> int:
...
def delete(self) -> int: ...

def metadata_visit_object(self) -> Visit:
...
def metadata_visit_object(self) -> Visit: ...

def refresh_from_db(self) -> None:
...
def refresh_from_db(self) -> None: ...


class PanelStub(Protocol):
Expand All @@ -77,34 +72,27 @@ class RequisitionMetadataModelStub(Protocol):
visit: VisitModel
_meta: ModelMetaStub

def save(self, *args, **kwargs) -> None:
...
def save(self, *args, **kwargs) -> None: ...

def delete(self) -> int:
...
def delete(self) -> int: ...

def metadata_visit_object(self) -> Visit:
...
def metadata_visit_object(self) -> Visit: ...

def metadata_updater_cls(self, **opts: dict):
...
def metadata_updater_cls(self, **opts: dict): ...


class MetadataGetterStub(Protocol):
metadata_objects: QuerySet
visit: RelatedVisitModelStub | None


class CrfMetadataUpdaterStub(Protocol):
...
class CrfMetadataUpdaterStub(Protocol): ...


class RequisitionMetadataUpdaterStub(Protocol):
...
class RequisitionMetadataUpdaterStub(Protocol): ...


class RequisitionMetadataGetterStub(MetadataGetterStub, Protocol):
...
class RequisitionMetadataGetterStub(MetadataGetterStub, Protocol): ...


class MetadataWrapperStub(Protocol):
Expand All @@ -114,11 +102,9 @@ class MetadataWrapperStub(Protocol):
...


class RequisitionMetadataWrapperStub(MetadataWrapperStub, Protocol):
...
class RequisitionMetadataWrapperStub(MetadataWrapperStub, Protocol): ...


class Predicate(Protocol):
@staticmethod
def get_value(self) -> Any:
...
def get_value(self) -> Any: ...
1 change: 0 additions & 1 deletion edc_metadata/tests/crf_test_helper.py
Expand Up @@ -5,7 +5,6 @@


class CrfTestHelper:

"""A test class to help create CRFs and manipulate
metadata.
"""
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Expand Up @@ -36,7 +36,7 @@ exclude =
effect_metadata.tests*

[flake8]
ignore = E226,W503,E203
ignore = E226,W503,E203,E701,E704
max-line-length = 95
max-complexity = 12
exclude = */migrations/*,.tox,.git,__pycache__,build,dist,.eggs,_version.py
Expand Down

0 comments on commit 60fe737

Please sign in to comment.