Skip to content

Commit

Permalink
refactor: register_with -> static __register__ export
Browse files Browse the repository at this point in the history
  • Loading branch information
Nytelife26 committed Jul 17, 2024
1 parent fca1779 commit 97f28e8
Show file tree
Hide file tree
Showing 126 changed files with 492 additions and 808 deletions.
2 changes: 1 addition & 1 deletion proselint/checks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def discover(self) -> None:
continue
try:
module = importlib.import_module(info.name, "proselint.checks")
module.register_with(self)
self.register_many(module.__register__)
log.debug(
"Registered from module %s at %.3fms",
module.__name__,
Expand Down
4 changes: 2 additions & 2 deletions proselint/checks/airlinese/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Airlinese."""

from proselint.checks.airlinese.misc import register_with
from proselint.checks.airlinese.misc import __register__

__all__ = ["register_with"]
__all__ = ["__register__"]
7 changes: 2 additions & 5 deletions proselint/checks/airlinese/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

from __future__ import annotations

from proselint.checks import CheckRegistry, CheckSpec, Existence
from proselint.checks import CheckSpec, Existence

examples_pass = [
"Smoke phrase with nothing flagged.",
Expand All @@ -37,7 +37,4 @@
"'{}' is airlinese.",
)


def register_with(registry: CheckRegistry) -> None:
"""Register the check."""
registry.register(check)
__register__ = (check,)
4 changes: 2 additions & 2 deletions proselint/checks/annotations/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Annotations."""

from proselint.checks.annotations.misc import register_with
from proselint.checks.annotations.misc import __register__

__all__ = ["register_with"]
__all__ = ["__register__"]
7 changes: 2 additions & 5 deletions proselint/checks/annotations/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

from __future__ import annotations

from proselint.checks import CheckRegistry, CheckSpec, Existence
from proselint.checks import CheckSpec, Existence

examples_pass = [
"Smoke phrase with nothing flagged.",
Expand All @@ -38,7 +38,4 @@
"Annotation left in text.",
)


def register_with(registry: CheckRegistry) -> None:
"""Register the check."""
registry.register(check)
__register__ = (check,)
4 changes: 2 additions & 2 deletions proselint/checks/archaism/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Archaism."""

from proselint.checks.archaism.misc import register_with
from proselint.checks.archaism.misc import __register__

__all__ = ["register_with"]
__all__ = ["__register__"]
7 changes: 2 additions & 5 deletions proselint/checks/archaism/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

from __future__ import annotations

from proselint.checks import CheckRegistry, CheckSpec, Existence
from proselint.checks import CheckSpec, Existence

examples_pass = [
"Smoke phrase with nothing flagged.",
Expand Down Expand Up @@ -86,7 +86,4 @@
"'{}' is archaic.",
)


def register_with(registry: CheckRegistry) -> None:
"""Register the check."""
registry.register(check)
__register__ = (check,)
11 changes: 3 additions & 8 deletions proselint/checks/cliches/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
"""Avoid cliches."""

from proselint.checks import CheckRegistry
from proselint.checks.cliches.hell import register_with as register_hell
from proselint.checks.cliches.misc import register_with as register_misc
from proselint.checks.cliches.hell import __register__ as register_hell
from proselint.checks.cliches.misc import __register__ as register_misc


def register_with(registry: CheckRegistry) -> None:
"""Register the checks."""
register_hell(registry)
register_misc(registry)
__register__ = (*register_hell, *register_misc)
9 changes: 3 additions & 6 deletions proselint/checks/cliches/hell.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

from __future__ import annotations

from proselint.checks import CheckFlags, CheckRegistry, CheckSpec, Existence
from proselint.checks import CheckFlags, CheckSpec, Existence

examples_pass = [
"Smoke phrase with nothing flagged.",
Expand All @@ -30,10 +30,7 @@
Existence(["all hell broke loose"]),
"cliches.hell",
"Never use the words 'all hell broke loose'.",
flags=CheckFlags(limit_results=3)
flags=CheckFlags(limit_results=3),
)


def register_with(registry: CheckRegistry) -> None:
"""Register the check."""
registry.register(check)
__register__ = (check,)
25 changes: 11 additions & 14 deletions proselint/checks/cliches/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from __future__ import annotations

from proselint.checks import CheckRegistry, CheckSpec, Existence
from proselint.checks import CheckSpec, Existence

examples_pass = [
"Smoke phrase with nothing flagged.",
Expand Down Expand Up @@ -1073,16 +1073,13 @@
msg,
)


def register_with(registry: CheckRegistry) -> None:
"""Register the checks."""
registry.register_many((
check_cliches_garner,
check_cliches_write_good_a_to_c,
check_cliches_write_good_d_to_j,
check_cliches_write_good_k_to_o,
check_cliches_write_good_p_to_s,
check_cliches_write_good_t_to_z,
check_cliches_gnu_diction,
check_cliches_nigel,
))
__register__ = (
check_cliches_garner,
check_cliches_write_good_a_to_c,
check_cliches_write_good_d_to_j,
check_cliches_write_good_k_to_o,
check_cliches_write_good_p_to_s,
check_cliches_write_good_t_to_z,
check_cliches_gnu_diction,
check_cliches_nigel,
)
11 changes: 3 additions & 8 deletions proselint/checks/consistency/__init__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
"""Various consistency checks."""

from proselint.checks import CheckRegistry
from proselint.checks.consistency.spacing import (
register_with as register_spacing,
__register__ as register_spacing,
)
from proselint.checks.consistency.spelling import (
register_with as register_spelling,
__register__ as register_spelling,
)


def register_with(registry: CheckRegistry) -> None:
"""Register the checks."""
register_spacing(registry)
register_spelling(registry)
__register__ = (*register_spacing, *register_spelling)
7 changes: 2 additions & 5 deletions proselint/checks/consistency/spacing.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from __future__ import annotations

from proselint.checks import CheckRegistry, CheckSpec, Consistency
from proselint.checks import CheckSpec, Consistency

examples_pass = [
"Smoke phrase with nothing flagged.",
Expand All @@ -33,7 +33,4 @@
ignore_case=False,
)


def register_with(registry: CheckRegistry) -> None:
"""Register the check."""
registry.register(check)
__register__ = (check,)
7 changes: 2 additions & 5 deletions proselint/checks/consistency/spelling.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

from __future__ import annotations

from proselint.checks import CheckRegistry, CheckSpec, Consistency
from proselint.checks import CheckSpec, Consistency

examples_pass = [
"Smoke phrase with nothing flagged.",
Expand Down Expand Up @@ -56,7 +56,4 @@
"Inconsistent spelling of '{}' (vs. '{}').",
)


def register_with(registry: CheckRegistry) -> None:
"""Register the check."""
registry.register(check)
__register__ = (check,)
4 changes: 2 additions & 2 deletions proselint/checks/corporate_speak/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Corporate-speak."""

from proselint.checks.corporate_speak.misc import register_with
from proselint.checks.corporate_speak.misc import __register__

__all__ = ["register_with"]
__all__ = ["__register__"]
7 changes: 2 additions & 5 deletions proselint/checks/corporate_speak/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

from __future__ import annotations

from proselint.checks import CheckRegistry, CheckSpec, Existence
from proselint.checks import CheckSpec, Existence

examples_pass = [
"Smoke phrase with nothing flagged.",
Expand Down Expand Up @@ -59,7 +59,4 @@
"Minimize your use of corporate catchphrases like this one.",
)


def register_with(registry: CheckRegistry) -> None:
"""Register the check."""
registry.register(check)
__register__ = (check,)
18 changes: 8 additions & 10 deletions proselint/checks/cursing/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
"""Cursing."""

from proselint.checks import CheckRegistry
from proselint.checks.cursing.filth import register_with as register_filth
from proselint.checks.cursing.nfl import register_with as register_nfl
from proselint.checks.cursing.nword import register_with as register_nword
from proselint.checks.cursing.filth import __register__ as register_filth
from proselint.checks.cursing.nfl import __register__ as register_nfl
from proselint.checks.cursing.nword import __register__ as register_nword


def register_with(registry: CheckRegistry) -> None:
"""Register the checks."""
register_filth(registry)
register_nfl(registry)
register_nword(registry)
__register__ = (
*register_filth,
*register_nfl,
*register_nword,
)
7 changes: 2 additions & 5 deletions proselint/checks/cursing/filth.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

from __future__ import annotations

from proselint.checks import CheckRegistry, CheckSpec, Existence
from proselint.checks import CheckSpec, Existence

examples_pass = [
"Smoke phrase with nothing flagged.",
Expand Down Expand Up @@ -44,7 +44,4 @@
),
)


def register_with(registry: CheckRegistry) -> None:
"""Register the check."""
registry.register(check)
__register__ = (check,)
19 changes: 8 additions & 11 deletions proselint/checks/cursing/nfl.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

from __future__ import annotations

from proselint.checks import CheckRegistry, CheckSpec, Existence, Pd
from proselint.checks import CheckSpec, Existence, Pd

examples_pass = [
"Smoke phrase with nothing flagged.",
Expand Down Expand Up @@ -1228,13 +1228,10 @@
msg,
)


def register_with(registry: CheckRegistry) -> None:
"""Register the checks."""
registry.register_many((
check_a_to_e,
check_f_to_h,
check_i_to_p,
check_q_to_z,
check_abb,
))
__register__ = (
check_a_to_e,
check_f_to_h,
check_i_to_p,
check_q_to_z,
check_abb,
)
7 changes: 2 additions & 5 deletions proselint/checks/cursing/nword.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

from __future__ import annotations

from proselint.checks import CheckRegistry, CheckSpec, Existence
from proselint.checks import CheckSpec, Existence

examples_pass = [
"Smoke phrase with nothing flagged.",
Expand All @@ -32,7 +32,4 @@
"Take responsibility for the shitty words you want to say.",
)


def register_with(registry: CheckRegistry) -> None:
"""Register the check."""
registry.register(check)
__register__ = (check,)
14 changes: 6 additions & 8 deletions proselint/checks/dates_times/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
"""Dates and times."""

from proselint.checks import CheckRegistry
from proselint.checks.dates_times.am_pm import register_with as register_am_pm
from proselint.checks.dates_times.am_pm import register_with as register_dates
from proselint.checks.dates_times.am_pm import __register__ as register_am_pm
from proselint.checks.dates_times.am_pm import __register__ as register_dates


def register_with(registry: CheckRegistry) -> None:
"""Register the checks."""
register_am_pm(registry)
register_dates(registry)
__register__ = (
*register_am_pm,
*register_dates,
)
17 changes: 7 additions & 10 deletions proselint/checks/dates_times/am_pm.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from __future__ import annotations

from proselint.checks import CheckRegistry, CheckSpec, Existence, Pd
from proselint.checks import CheckSpec, Existence, Pd

examples_pass = [
"Smoke phrase with nothing flagged.",
Expand Down Expand Up @@ -72,12 +72,9 @@
"'a.m.' is always morning; 'p.m.' is always night.",
)


def register_with(registry: CheckRegistry) -> None:
"""Register the checks."""
registry.register_many((
check_lowercase_periods,
check_spacing,
check_midnight_noon,
check_redundancy,
))
__register__ = (
check_lowercase_periods,
check_spacing,
check_midnight_noon,
check_redundancy,
)
Loading

0 comments on commit 97f28e8

Please sign in to comment.