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 6667208 commit 15e74ca
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 43 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.3.0
rev: 24.1.1
hooks:
- id: black
language_version: python3.10

- repo: https://github.com/pycqa/flake8
rev: 6.0.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 @@ -42,7 +42,7 @@ repos:
- id: detect-private-key

- repo: https://github.com/adrienverge/yamllint
rev: v1.31.0
rev: v1.33.0
hooks:
- id: yamllint
args:
Expand Down
1 change: 0 additions & 1 deletion edc_visit_tracking/form_validators/visit_form_validator.py
Expand Up @@ -33,7 +33,6 @@


class VisitFormValidator(WindowPeriodFormValidatorMixin, FormValidator):

"""Form validator for visit models (e.g. subject_visit).
See also `report_datetime` checks in the
Expand Down
Expand Up @@ -11,7 +11,6 @@


class SubjectVisitMissedModelMixin(models.Model):

"""Declare with:
missed_reasons = models.ManyToManyField(SubjectVisitMissedReasons, blank=True)
Expand Down
Expand Up @@ -30,7 +30,6 @@ class VisitModelMixin(
RequiresConsentFieldsModelMixin,
models.Model,
):

"""
For example:
Expand Down
Expand Up @@ -13,7 +13,6 @@


class CrfModelAdminMixin:

"""ModelAdmin subclass for models with a ForeignKey to your
visit model(s).
"""
Expand Down
Expand Up @@ -21,7 +21,6 @@


class VisitModelAdminMixin(DocumentStatusModelAdminMixin):

"""ModelAdmin subclass for models with a ForeignKey to
'appointment', such as your visit model(s).
Expand Down
24 changes: 8 additions & 16 deletions edc_visit_tracking/stubs.py
Expand Up @@ -21,29 +21,21 @@ class RelatedVisitModelStub(Protocol):
objects: models.Manager
_meta: ModelMetaStub

def natural_key(self) -> tuple:
...
def natural_key(self) -> tuple: ...

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

def related_visit_model_attr(self) -> str:
...
def related_visit_model_attr(self) -> str: ...

def get_visit_reason_no_follow_up_choices(self) -> list:
...
def get_visit_reason_no_follow_up_choices(self) -> list: ...

def get_reason_display(self) -> str:
...
def get_reason_display(self) -> str: ...

def get_reason_unscheduled_display(self) -> str:
...
def get_reason_unscheduled_display(self) -> str: ...

def get_require_crfs_display(self) -> str:
...
def get_require_crfs_display(self) -> str: ...

def update_document_status_on_save(self, update_fields=None) -> None:
...
def update_document_status_on_save(self, update_fields=None) -> None: ...


TRelatedVisitModelStub = TypeVar("TRelatedVisitModelStub", bound="RelatedVisitModelStub")
21 changes: 7 additions & 14 deletions edc_visit_tracking/typing_stubs.py
Expand Up @@ -23,29 +23,23 @@

class ModelBase(type):
@property
def objects(cls: type[_Self]) -> BaseManager[_Self]:
...
def objects(cls: type[_Self]) -> BaseManager[_Self]: ...

@property
def _default_manager(cls: type[_Self]) -> BaseManager[_Self]:
...
def _default_manager(cls: type[_Self]) -> BaseManager[_Self]: ...

@property
def _base_manager(cls: type[_Self]) -> BaseManager[_Self]:
...
def _base_manager(cls: type[_Self]) -> BaseManager[_Self]: ...


class Options(Generic[_M]):
def label_lower(self) -> str:
...
def label_lower(self) -> str: ...

def fields(self) -> Tuple[Field]:
...
def fields(self) -> Tuple[Field]: ...

def get_fields(
self, include_parents: bool = ..., include_hidden: bool = ...
) -> list[Field | ForeignObjectRel | GenericForeignKey]:
...
) -> list[Field | ForeignObjectRel | GenericForeignKey]: ...


class SiteFieldsProtocol(Protocol):
Expand All @@ -58,8 +52,7 @@ class RelatedVisitProtocol(VisitScheduleFieldsProtocol, Protocol):
metadata_destroyer_cls: Type[Destroyer]
metadata_rule_evaluator_cls: Type[MetadataRuleEvaluator]

class Meta:
...
class Meta: ...

_meta: Options[Any]

Expand Down
1 change: 0 additions & 1 deletion edc_visit_tracking/visit_sequence.py
Expand Up @@ -17,7 +17,6 @@ class VisitSequenceError(Exception):


class VisitSequence:

"""A class that calculates the previous_visit and can enforce
that visits are filled in sequence.
"""
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Expand Up @@ -34,7 +34,7 @@ exclude =
edc_visit_tracking.tests*

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

0 comments on commit 15e74ca

Please sign in to comment.