A collection of design patterns/idioms in Python
This report summarizes scanner evidence for faif/python-patterns, a Python project with 43,045 GitHub stars. SynthScan examined 5,542 lines of code across 84 source files, recording 102 pattern matches distributed across 8 syntactic categories. The legacy adjusted pattern signal is 25.2 (Elevated pattern signal); it is not an authorship estimate.
Use the findings to ask whether maintainers can explain intent, verify dependencies, simplify unnecessary scaffolding, and focus review effort. Risk Payload v1 adds ownership, supply-chain, over-engineering, and review-effort vectors when available. These are prompts for human verification, not probabilities, security findings, or measured maintenance costs.
Use each vector to guide manual verification of the underlying findings.
Can maintainers explain intent, assumptions, and trade-offs? 89 finding(s).
Are imports declared and package/API names verified? 10 finding(s).
Are wrappers, guards, and repeated structures necessary? 85 finding(s).
Which changes need focused human review? 102 finding(s).
This chart tracks the legacy adjusted pattern score across scan runs. Changes can reflect source changes, scan coverage, or detector/scoring versions; they do not measure AI adoption or prove that a team refactored code. Compare runs only when their scoring versions are compatible. The dashed line tracks the raw pattern-hit count.
Groups findings by configured severity weight. Severity is not a confidence estimate, security rating, or proof that a package is missing. Verify imports against the project's manifests and inspect each finding in its local design context.
This horizontal bar chart shows where configured pattern scores accumulate across directories. Treat the bars as locations to inspect, not as evidence of authorship or code quality. Use the file-level findings to decide whether a directory needs a focused ownership, dependency, complexity, or review check.
The scanner identified 102 distinct pattern matches across 8 syntactic categories. Each entry below represents a discrete location in the source code where the engine recorded a detector match to inspect in context. Expand any category row to inspect the individual file paths, line numbers, code snippets, and the lexical context (CODE, COMMENT, or STRING) in which each match was detected.
Reading the findings table: The Severity column indicates the configured finding weight (CRITICAL / HIGH / MEDIUM / LOW). The Context column identifies whether the match occurred inside executable code, an inline comment, or a string literal — legacy comment-context matches receive a ×1.5 score weight. The ⚡ bolt icon marks clustered matches: three or more patterns within a 10-line window, each receiving an additional ×1.5 density multiplier under the legacy scoring model.
| Severity | File | Line | Snippet | Context |
|---|---|---|---|---|
| LOW | patterns/dependency_injection.py | 19 | def get_current_time_as_html_fragment(self): | STRING |
| LOW | patterns/dependency_injection.py | 34 | def get_current_time_as_html_fragment(self) -> str: | CODE |
| LOW | patterns/dependency_injection.py | 46 | def get_current_time_as_html_fragment(self, time_provider: Callable) -> str: | CODE |
| LOW | patterns/dependency_injection.py | 63 | def get_current_time_as_html_fragment(self): | CODE |
| LOW | patterns/dependency_injection.py | 71 | def production_code_time_provider() -> str: | CODE |
| LOW | patterns/other/hsm/hsm.py | 51 | def _send_diagnostics_request(self): | CODE |
| LOW⚡ | patterns/other/hsm/hsm.py | 63 | def _send_switchover_response(self): | CODE |
| LOW⚡ | patterns/other/hsm/hsm.py | 66 | def _send_operator_inservice_response(self): | CODE |
| LOW⚡ | patterns/other/hsm/hsm.py | 69 | def _send_diagnostics_failure_report(self): | CODE |
| LOW⚡ | patterns/other/hsm/hsm.py | 72 | def _send_diagnostics_pass_report(self): | CODE |
| LOW⚡ | tests/test_hsm.py | 21 | def test_initial_state_shall_be_standby(cls): | CODE |
| LOW⚡ | tests/test_hsm.py | 24 | def test_unsupported_state_shall_raise_exception(cls): | CODE |
| LOW⚡ | tests/test_hsm.py | 28 | def test_unsupported_message_type_shall_raise_exception(cls): | CODE |
| LOW⚡ | tests/test_hsm.py | 32 | def test_calling_next_state_shall_change_current_state(cls): | CODE |
| LOW⚡ | tests/test_hsm.py | 38 | def test_method_perform_switchover_shall_return_specifically(cls): | CODE |
| LOW | tests/test_hsm.py | 57 | def test_given_standby_on_message_switchover_shall_set_active(cls): | CODE |
| LOW | tests/test_hsm.py | 61 | def test_given_standby_on_message_switchover_shall_call_hsm_methods(cls): | CODE |
| LOW⚡ | tests/test_hsm.py | 76 | def test_given_standby_on_message_fault_trigger_shall_set_suspect(cls): | CODE |
| LOW⚡ | tests/test_hsm.py | 80 | def test_given_standby_on_message_diagnostics_failed_shall_raise_exception_and_keep_in_state( | CODE |
| LOW⚡ | tests/test_hsm.py | 87 | def test_given_standby_on_message_diagnostics_passed_shall_raise_exception_and_keep_in_state( | CODE |
| LOW⚡ | tests/test_hsm.py | 94 | def test_given_standby_on_message_operator_inservice_shall_raise_exception_and_keep_in_state( | CODE |
| LOW | tests/test_graph_search.py | 4 | def test_find_shortest_path_bfs_handles_leaf_nodes_without_outgoing_edges(): | CODE |
| LOW⚡ | tests/creational/test_factory.py | 13 | def test_get_localizer_english(self): | CODE |
| LOW⚡ | tests/creational/test_factory.py | 19 | def test_get_localizer_default(self): | CODE |
| LOW⚡ | tests/creational/test_factory.py | 24 | def test_get_localizer_unknown_language(self): | CODE |
| LOW⚡ | tests/creational/test_prototype.py | 10 | def test_cloning_propperty_innate_values(self): | CODE |
| LOW⚡ | tests/creational/test_prototype.py | 15 | def test_extended_property_values_cloning(self): | CODE |
| LOW⚡ | tests/creational/test_prototype.py | 21 | def test_cloning_propperty_assigned_values(self): | CODE |
| LOW | tests/creational/test_prototype.py | 41 | def test_particular_properties_retrieving(self): | CODE |
| LOW | tests/creational/test_prototype.py | 46 | def test_extended_properties_retrieving(self): | CODE |
| LOW | tests/creational/test_abstract_factory.py | 7 | def test_dog_pet_shop_shall_show_dog_instance(self): | CODE |
| LOW⚡ | tests/creational/test_borg.py | 15 | def test_initial_borg_state_shall_be_init(self): | CODE |
| LOW⚡ | tests/creational/test_borg.py | 19 | def test_changing_instance_attribute_shall_change_borg_state(self): | CODE |
| LOW⚡ | tests/creational/test_borg.py | 25 | def test_instances_shall_have_own_ids(self): | CODE |
| LOW | tests/creational/test_lazy.py | 15 | def test_relatives_not_in_properties(self): | CODE |
| LOW | tests/creational/test_lazy.py | 27 | def test_relatives_after_access(self): | CODE |
| LOW | tests/creational/test_pool.py | 35 | def test_pool_behavior_with_single_object_inside(self): | CODE |
| LOW⚡ | tests/behavioral/test_catalog.py | 9 | def test_catalog_multiple_methods(): | CODE |
| LOW⚡ | tests/behavioral/test_catalog.py | 15 | def test_catalog_multiple_instance_methods(): | CODE |
| LOW⚡ | tests/behavioral/test_catalog.py | 21 | def test_catalog_multiple_class_methods(): | CODE |
| LOW⚡ | tests/behavioral/test_catalog.py | 27 | def test_catalog_multiple_static_methods(): | CODE |
| LOW⚡ | tests/behavioral/test_strategy.py | 14 | def test_discount_function_return(func, order, discount): | CODE |
| LOW⚡ | tests/behavioral/test_strategy.py | 21 | def test_order_discount_strategy_validate_success(func, price): | CODE |
| LOW⚡ | tests/behavioral/test_strategy.py | 28 | def test_order_discount_strategy_validate_error(): | CODE |
| LOW⚡ | tests/behavioral/test_strategy.py | 38 | def test_discount_apply_success(func, price, discount): | CODE |
| LOW | tests/behavioral/test_memento.py | 11 | def test_rollback_on_transaction(): | CODE |
| LOW | tests/behavioral/test_memento.py | 28 | def test_rollback_with_transactional_annotation(): | CODE |
| LOW | tests/behavioral/test_observer.py | 24 | def test_one_data_change_notifies_each_observer_once(observable): | CODE |
| LOW⚡ | tests/behavioral/test_publish_subscribe.py | 11 | def test_subscriber_shall_be_attachable_to_subscriptions(cls): | CODE |
| LOW⚡ | tests/behavioral/test_publish_subscribe.py | 19 | def test_subscriber_shall_be_detachable_from_subscriptions(cls): | CODE |
| LOW⚡ | tests/behavioral/test_publish_subscribe.py | 28 | def test_publisher_shall_append_subscription_message_to_queue(cls): | CODE |
| LOW | tests/behavioral/test_publish_subscribe.py | 39 | def test_provider_shall_update_affected_subscribers_with_published_subscription( | CODE |
| LOW⚡ | tests/behavioral/test_visitor.py | 11 | def test_visiting_generic_node(visitor): | CODE |
| LOW⚡ | tests/behavioral/test_visitor.py | 17 | def test_visiting_specific_nodes(visitor): | CODE |
| LOW⚡ | tests/behavioral/test_visitor.py | 23 | def test_visiting_inherited_nodes(visitor): | CODE |
| LOW | tests/fundamental/test_delegation.py | 6 | def test_delegator_delegates_attribute_and_call(): | CODE |
| LOW | tests/fundamental/test_delegation.py | 13 | def test_delegator_missing_attribute_raises(): | CODE |
| LOW⚡ | tests/structural/test_flyweight_with_metaclass.py | 4 | def test_same_arguments_share_an_instance(): | CODE |
| LOW⚡ | tests/structural/test_flyweight_with_metaclass.py | 9 | def test_different_arguments_do_not_share_an_instance(): | CODE |
| LOW⚡ | tests/structural/test_flyweight_with_metaclass.py | 14 | def test_argument_boundaries_are_part_of_the_key(): | CODE |
| 22 more matches not shown… | ||||
| Severity | File | Line | Snippet | Context |
|---|---|---|---|---|
| LOW | patterns/creational/prototype.py | 24 | CODE | |
| LOW | patterns/behavioral/observer.py | 14 | CODE | |
| LOW | patterns/behavioral/mediator.py | 11 | CODE | |
| LOW | patterns/behavioral/strategy.py | 10 | CODE | |
| LOW | patterns/behavioral/iterator_alt.py | 8 | CODE | |
| LOW | patterns/behavioral/publish_subscribe.py | 7 | CODE | |
| LOW | patterns/behavioral/state.py | 11 | CODE | |
| LOW | patterns/behavioral/chaining_method.py | 1 | CODE | |
| LOW | patterns/fundamental/delegation_pattern.py | 9 | CODE | |
| LOW | patterns/structural/front_controller.py | 8 | CODE |
| Severity | File | Line | Snippet | Context |
|---|---|---|---|---|
| HIGH | patterns/behavioral/servant.py | 59 | Calculate the area of a given shape. Args: shape: The geometric shape whose area is to be | STRING |
| HIGH | patterns/behavioral/servant.py | 80 | Calculate the perimeter of a given shape. Args: shape: The geometric shape whose perimeter | STRING |
| Severity | File | Line | Snippet | Context |
|---|---|---|---|---|
| HIGH | patterns/behavioral/observer.py | 56 | except ValueError: | CODE |
| Severity | File | Line | Snippet | Context |
|---|---|---|---|---|
| LOW | patterns/other/graph_search.py | 40 | CODE | |
| LOW | patterns/other/graph_search.py | 57 | CODE |
| Severity | File | Line | Snippet | Context |
|---|---|---|---|---|
| LOW | patterns/behavioral/memento.py | 66 | except Exception as e: | CODE |
| LOW | patterns/structural/mvc.py | 128 | except Exception: | CODE |
| Severity | File | Line | Snippet | Context |
|---|---|---|---|---|
| LOW | patterns/behavioral/memento.py | 84 | def do_stuff(self) -> None: | CODE |
| LOW | patterns/fundamental/delegation_pattern.py | 53 | def do_something(self, something: str, kw=None) -> str: | CODE |
| Severity | File | Line | Snippet | Context |
|---|---|---|---|---|
| LOW | patterns/structural/flyweight.py | 43 | # If the object exists in the pool - just return it | COMMENT |