Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hug multiline-strings preview style #9243

Merged
merged 1 commit into from
Jan 10, 2024
Merged

Hug multiline-strings preview style #9243

merged 1 commit into from
Jan 10, 2024

Conversation

MichaReiser
Copy link
Member

@MichaReiser MichaReiser commented Dec 22, 2023

Summary

This PR implements the hugging for multiline strings in call expression.

The implementation doesn't match black's behavior exactly yet:

  1. Black removes the hugging for nested calls call(nested("""multiline\nstring")). Ruff will not to ensure consistency with hug_parentheses
  2. Black applies the hugging even for "multiline" % placeholder strings. This can get pretty hard to read if the formatting has many arguments. The solution here is to use f-strings instead.
  3. Black avoids parenthesizing lambdas with a multiline string body, Ruff parenthesizes it.

I find 1 and 2 acceptable and wouldn't support them. 3. is a pre-existing deviation that we should tackle separately.

Test Plan

  • I added tests documenting the deviations
  • I reviewed the snapshot changes
  • This PR increases the poetry compatbility from 0.99905 to 0.99934
  • I reviewed the ecosystem changes. I like what I see. I only noticed that the last line of the multiline string now tends to have one indent too much. There isn't anything we can do about it without knowing if it is safe to trim the last string or not (depends on the called function). This is something that requires manual intervention.
a = call(
	"""
	Multiline string
	"""
)

becomes

a = call("""
	Multiline string
	""")

@MichaReiser MichaReiser linked an issue Dec 22, 2023 that may be closed by this pull request
@MichaReiser MichaReiser added formatter Related to the formatter preview Related to preview mode features labels Dec 22, 2023
Copy link
Contributor

github-actions bot commented Dec 22, 2023

ruff-ecosystem results

Formatter (stable)

ℹ️ ecosystem check detected format changes. (+5 -6 lines in 2 files in 2 projects; 41 projects unchanged)

demisto/content (+2 -5 lines across 1 file)

ruff format --no-preview --exclude Packs/ThreatQ/Integrations/ThreatQ/ThreatQ.py

Packs/IntegrationsAndIncidentsHealthCheck/Scripts/GetFailedTasks/GetFailedTasks.py~L107

     )
 
     if is_error(response):
-        error = (
-            f'Failed retrieving tasks for incident ID {incident["id"]}.\n \
+        error = f'Failed retrieving tasks for incident ID {incident["id"]}.\n \
            Make sure that the API key configured in the Core REST API integration \
-is one with sufficient permissions to access that incident.\n'
-            + get_error(response)
-        )
+is one with sufficient permissions to access that incident.\n' + get_error(response)
         raise Exception(error)
 
     return response[0]["Contents"]["response"]

reflex-dev/reflex (+3 -1 lines across 1 file)

reflex/components/markdown/markdown.py~L259

         }
 
         # Separate out inline code and code blocks.
-        components["code"] = f"""{{({{node, inline, className, {_CHILDREN._var_name}, {_PROPS._var_name}}}) => {{
+        components[
+            "code"
+        ] = f"""{{({{node, inline, className, {_CHILDREN._var_name}, {_PROPS._var_name}}}) => {{
     const match = (className || '').match(/language-(?<lang>.*)/);
     const language = match ? match[1] : '';
     if (language) {{

Formatter (preview)

ℹ️ ecosystem check detected format changes. (+2971 -5900 lines in 374 files in 31 projects; 12 projects unchanged)

RasaHQ/rasa (+326 -652 lines across 19 files)

ruff format --preview

rasa/telemetry.py~L105

 
 def print_telemetry_reporting_info() -> None:
     """Print telemetry information to std out."""
-    message = textwrap.dedent(
-        f"""
+    message = textwrap.dedent(f"""
         Rasa Open Source reports anonymous usage telemetry to help improve the product
         for all its users.
 
         If you'd like to opt-out, you can use `rasa telemetry disable`.
-        To learn more, check out {DOCS_URL_TELEMETRY}."""
-    ).strip()
+        To learn more, check out {DOCS_URL_TELEMETRY}.""").strip()
 
     table = SingleTable([[message]])
     print(table.table)

tests/cli/test_utils.py~L357

     file_type: Text, data_type: Text, tmp_path: Path
 ):
     file_name = tmp_path / f"{file_type}.yml"
-    file_name.write_text(
-        f"""
+    file_name.write_text(f"""
         version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
         {file_type}:
         - {data_type}: test path
           steps:
           - intent: goodbye
           - action: action_test
-        """
-    )
+        """)
 
     importer = TrainingDataImporter.load_from_config(
         "data/test_config/config_defaults.yml",

tests/cli/test_utils.py~L389

     file_type: Text, data_type: Text, tmp_path: Path
 ):
     file_name = tmp_path / f"{file_type}.yml"
-    file_name.write_text(
-        f"""
+    file_name.write_text(f"""
         version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
         {file_type}:
         - {data_type}: test path

tests/cli/test_utils.py~L398

             - intent: request_restaurant
             - action: restaurant_form
             - active_loop: restaurant_form
-        """
-    )
+        """)
 
     importer = TrainingDataImporter.load_from_config(
         "data/test_config/config_defaults.yml",

tests/cli/test_utils.py~L425

     )
     nlu_file = "data/test_nlu/test_nlu_validate_files_with_active_loop_null.yml"
     file_name = tmp_path / f"{file_type}.yml"
-    file_name.write_text(
-        f"""
+    file_name.write_text(f"""
         version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
         {file_type}:
         - {data_type}: test path

tests/cli/test_utils.py~L436

             - active_loop: restaurant_form
             - active_loop: null
             - action: action_search_restaurants
-        """
-    )
+        """)
 
     importer = TrainingDataImporter.load_from_config(
         "data/test_config/config_unique_assistant_id.yml",

tests/cli/test_utils.py~L464

 
 def test_validate_files_form_slots_not_matching(tmp_path: Path):
     domain_file_name = tmp_path / "domain.yml"
-    domain_file_name.write_text(
-        f"""
+    domain_file_name.write_text(f"""
         version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
         forms:
           name_form:

tests/cli/test_utils.py~L481

                 type: text
                 mappings:
                 - type: from_text
-        """
-    )
+        """)
 
     importer = TrainingDataImporter.load_from_config(
         "data/test_config/config_defaults.yml",

tests/cli/test_utils.py~L536

     tested_slot = "duration"
     form_name = "booking_form"
     # form required_slots does not include the tested_slot
-    domain.write_text(
-        f"""
+    domain.write_text(f"""
             version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
             intents:
             - state_length_of_time

tests/cli/test_utils.py~L561

               {form_name}:
                 required_slots:
                 - location
-                """
-    )
+                """)
     importer = TrainingDataImporter.load_from_config(
         "data/test_config/config_defaults.yml", str(domain), None
     )

tests/core/actions/test_forms.py~L44

     form_name = "my form"
     action = FormAction(form_name, None)
     slot_name = "num_people"
-    domain = textwrap.dedent(
-        f"""
+    domain = textwrap.dedent(f"""
     slots:
       {slot_name}:
         type: float

tests/core/actions/test_forms.py~L59

     responses:
       utter_ask_num_people:
       - text: "How many people?"
-      """
-    )
+      """)
     domain = Domain.from_yaml(domain)
 
     events = await action.run(

tests/core/actions/test_forms.py~L81

     domain_required_slot_name = "num_people"
     slot_set_by_remote_custom_extraction_method = "some_slot"
     slot_value_set_by_remote_custom_extraction_method = "anything"
-    domain = textwrap.dedent(
-        f"""
+    domain = textwrap.dedent(f"""
     slots:
       {domain_required_slot_name}:
         type: float

tests/core/actions/test_forms.py~L102

       - text: "How many people?"
     actions:
       - validate_{form_name}
-      """
-    )
+      """)
     domain = Domain.from_yaml(domain)
 
     form_validation_events = [

tests/core/actions/test_forms.py~L141

     form_name = "my form"
     action = FormAction(form_name, None)
     slot_name = "num_people"
-    domain = textwrap.dedent(
-        f"""
+    domain = textwrap.dedent(f"""
     slots:
       {slot_name}:
         type: float

tests/core/actions/test_forms.py~L158

     responses:
       utter_ask_num_people:
       - text: "How many people?"
-      """
-    )
+      """)
     domain = Domain.from_yaml(domain)
 
     events = await action.run(

tests/core/actions/test_forms.py~L869

 def test_temporary_tracker():
     extra_slot = "some_slot"
     sender_id = "test"
-    domain = Domain.from_yaml(
-        f"""
+    domain = Domain.from_yaml(f"""
         version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
         slots:
           {extra_slot}:
             type: any
             mappings:
             - type: from_text
-        """
-    )
+        """)
 
     previous_events = [ActionExecuted(ACTION_LISTEN_NAME)]
     old_tracker = DialogueStateTracker.from_events(

tests/core/actions/test_forms.py~L1543

     form = FormAction(form_name, None)
 
     domain = Domain.from_yaml(
-        textwrap.dedent(
-            f"""
+        textwrap.dedent(f"""
             version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
             intent:
             - greet

tests/core/actions/test_forms.py~L1573

                required_slots:
                  - email
                  - name
-            """
-        )
+            """)
     )
 
     tracker = DialogueStateTracker.from_events(

tests/core/actions/test_forms.py~L1615

     form = FormAction(form_name, None)
 
     domain = Domain.from_yaml(
-        textwrap.dedent(
-            f"""
+        textwrap.dedent(f"""
             version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
             intent:
             - greet

tests/core/actions/test_forms.py~L1645

                required_slots:
                  - email
                  - name
-            """
-        )
+            """)
     )
 
     tracker = DialogueStateTracker.from_events(

tests/core/actions/test_forms.py~L1685

 
 
 async def test_action_extract_slots_custom_mapping_with_condition():
-    domain_yaml = textwrap.dedent(
-        f"""
+    domain_yaml = textwrap.dedent(f"""
         version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
 
         slots:

tests/core/actions/test_forms.py~L1705

 
         actions:
         - validate_some_form
-        """
-    )
+        """)
     domain = Domain.from_yaml(domain_yaml)
     events = [ActiveLoop("some_form"), UserUttered("Hi")]
     tracker = DialogueStateTracker.from_events(

tests/core/actions/test_forms.py~L1747

 
 async def test_form_slots_empty_with_restart():
     domain = Domain.from_yaml(
-        textwrap.dedent(
-            f"""
+        textwrap.dedent(f"""
             version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
             intent:
             - greet

tests/core/actions/test_forms.py~L1768

              some_form:
                required_slots:
                  - name
-            """
-        )
+            """)
     )
 
     tracker = DialogueStateTracker.from_events(

tests/core/actions/test_forms.py~L1811

 
     form_name = "test_form"
 
-    domain = Domain.from_yaml(
-        f"""
+    domain = Domain.from_yaml(f"""
     entities:
     - {entity_name}
     slots:

tests/core/actions/test_forms.py~L1827

       {form_name}:
         {REQUIRED_SLOTS_KEY}:
             - {slot_name}
-    """
-    )
+    """)
 
     events = [
         ActionExecuted("action_listen"),

tests/core/actions/test_forms.py~L1879

     action_server = EndpointConfig(ACTION_SERVER_URL)
     action = FormAction(form_name, action_server)
     slot_name = "num_people"
-    domain = textwrap.dedent(
-        f"""
+    domain = textwrap.dedent(f"""
     slots:
       {slot_name}:
         type: float

tests/core/actions/test_forms.py~L1896

       - text: "How many people?"
     actions:
       - validate_{form_name}
-    """
-    )
+    """)
     domain = Domain.from_yaml(domain)
     form_validation_events = [
         {

tests/core/actions/test_forms.py~L1949

     required_slot = "send_sms"
     global_slot = "membership"
 
-    domain = textwrap.dedent(
-        f"""
+    domain = textwrap.dedent(f"""
     intents:
     - start_form
     entities:

tests/core/actions/test_forms.py~L1988

       - text: "Would you like to receive an SMS?"
     actions:
       - validate_{form}
-    """
-    )
+    """)
     domain = Domain.from_yaml(domain)
 
     tracker = DialogueStateTracker.from_events(

tests/core/actions/test_forms.py~L2055

     dynamic_slot = "customer_name"
     bot_utterance = "What is your name?"
 
-    domain = textwrap.dedent(
-        f"""
+    domain = textwrap.dedent(f"""
     intents:
     - start_form
 

tests/core/actions/test_forms.py~L2075

       - text: "{bot_utterance}"
     actions:
       - validate_{form}
-    """
-    )
+    """)
     domain = Domain.from_yaml(domain)
 
     tracker = DialogueStateTracker.from_events(

tests/core/policies/test_rule_policy.py~L157

     # conversation start -> ensure that this isn't flagged as a contradiction.
 
     utter_anti_greet_action = "utter_anti_greet"
-    domain = Domain.from_yaml(
-        f"""
+    domain = Domain.from_yaml(f"""
         version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
         intents:
         - {GREET_INTENT_NAME}
         actions:
         - {UTTER_GREET_ACTION}
         - {utter_anti_greet_action}
-        """
-    )
+        """)
 
     greet_rule_at_conversation_start = TrackerWithCachedStates.from_events(
         "greet rule at conversation start",

tests/core/policies/test_rule_policy.py~L210

     utter_anti_greet_action = "utter_anti_greet"
     some_slot = "slot1"
     some_slot_initial_value = "slot1value"
-    domain = Domain.from_yaml(
-        f"""
+    domain = Domain.from_yaml(f"""
         version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
         intents:
         - {GREET_INTENT_NAME}

tests/core/policies/test_rule_policy.py~L224

             initial_value: {some_slot_initial_value}
             mappings:
             - type: from_text
-        """
-    )
+        """)
     greet_rule_at_conversation_start = TrackerWithCachedStates.from_events(
         "greet rule at conversation start",
         domain=domain,

tests/core/policies/test_rule_policy.py~L283

     utter_anti_greet_action = "utter_anti_greet"
     some_slot = "slot1"
     some_slot_initial_value = "slot1value"
-    domain = Domain.from_yaml(
-        f"""
+    domain = Domain.from_yaml(f"""
         version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
         intents:
         - {GREET_INTENT_NAME}

tests/core/policies/test_rule_policy.py~L297

             initial_value: {some_slot_initial_value}
             mappings:
             - type: from_text
-        """
-    )
+        """)
 
     greet_rule_at_conversation_start = TrackerWithCachedStates.from_events(
         "greet rule at conversation start",

tests/core/policies/test_rule_policy.py~L348

 
 
 def test_restrict_multiple_user_inputs_in_rules(policy: RulePolicy):
-    domain = Domain.from_yaml(
-        f"""
+    domain = Domain.from_yaml(f"""
         version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
         intents:
         - {GREET_INTENT_NAME}
         actions:
         - {UTTER_GREET_ACTION}
-        """
-    )
+        """)
 
     greet_events = [
         UserUttered(intent={"name": GREET_INTENT_NAME}),

tests/core/policies/test_rule_policy.py~L380

 def test_incomplete_rules_due_to_slots(policy: RulePolicy):
     some_action = "some_action"
     some_slot = "some_slot"
-    domain = Domain.from_yaml(
-        f"""
+    domain = Domain.from_yaml(f"""
         version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
         intents:
         - {GREET_INTENT_NAME}

tests/core/policies/test_rule_policy.py~L392

             type: text
             mappings:
             - type: from_text
-        """
-    )
+        """)
 
     complete_rule = TrackerWithCachedStates.from_events(
         "complete_rule",

tests/core/policies/test_rule_policy.py~L450

 def test_no_incomplete_rules_due_to_slots_after_listen(policy: RulePolicy):
     some_action = "some_action"
     some_slot = "some_slot"
-    domain = Domain.from_yaml(
-        f"""
+    domain = Domain.from_yaml(f"""
         version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
         intents:
         - {GREET_INTENT_NAME}

tests/core/policies/test_rule_policy.py~L464

             type: text
             mappings:
             - type: from_text
-        """
-    )
+        """)
 
     complete_rule = TrackerWithCachedStates.from_events(
         "complete_rule",

tests/core/policies/test_rule_policy.py~L512

     some_slot_value = "value1"
     some_other_slot = "some_other_slot"
     some_other_slot_value = "value2"
-    domain = Domain.from_yaml(
-        f"""
+    domain = Domain.from_yaml(f"""
         version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
         intents:
         - {GREET_INTENT_NAME}

tests/core/policies/test_rule_policy.py~L528

             type: text
             mappings:
             - type: from_text
-        """
-    )
+        """)
 
     simple_rule = TrackerWithCachedStates.from_events(
         "simple rule with an action that sets 1 slot",

tests/core/policies/test_rule_policy.py~L567

 
 def test_incomplete_rules_due_to_loops(policy: RulePolicy):
     some_form = "some_form"
-    domain = Domain.from_yaml(
-        f"""
+    domain = Domain.from_yaml(f"""
         version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
         intents:
         - {GREET_INTENT_NAME}
         forms:
           {some_form}:
             required_slots: []
-        """
-    )
+        """)
 
     complete_rule = TrackerWithCachedStates.from_events(
         "complete_rule",

tests/core/policies/test_rule_policy.py~L632

 
 def test_contradicting_rules(policy: RulePolicy):
     utter_anti_greet_action = "utter_anti_greet"
-    domain = Domain.from_yaml(
-        f"""
+    domain = Domain.from_yaml(f"""
         version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
         intents:
         - {GREET_INTENT_NAME}
         actions:
         - {UTTER_GREET_ACTION}
         - {utter_anti_greet_action}
-        """
-    )
+        """)
 
     anti_greet_rule = TrackerWithCachedStates.from_events(
         "anti greet rule",

tests/core/policies/test_rule_policy.py~L672

 
 def test_contradicting_rules_and_stories(policy: RulePolicy):
     utter_anti_greet_action = "utter_anti_greet"
-    domain = Domain.from_yaml(
-        f"""
+    domain = Domain.from_yaml(f"""
         version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
         intents:
         - {GREET_INTENT_NAME}
         actions:
         - {UTTER_GREET_ACTION}
         - {utter_anti_greet_action}
-        """
-    )
+        """)
 
     anti_greet_story = TrackerWithCachedStates.from_events(
         "anti greet story",

tests/core/policies/test_rule_policy.py~L816

 
 
 def test_faq_rule(policy: RulePolicy):
-    domain = Domain.from_yaml(
-        f"""
+    domain = Domain.from_yaml(f"""
         version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
         intents:
         - {GREET_INTENT_NAME}
         actions:
         - {UTTER_GREET_ACTION}
-        """
-    )
+        """)
 
     policy.train([GREET_RULE], domain)
     # remove first ... action and utter_greet and last action_listen from greet rule

tests/core/policies/test_rule_policy.py~L843

 async def test_predict_form_action_if_in_form(policy: RulePolicy):
     form_name = "some_form"
 
-    domain = Domain.from_yaml(
-        f"""
+    domain = Domain.from_yaml(f"""
         version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
         intents:
         - {GREET_INTENT_NAME}

tests/core/policies/test_rule_policy.py~L859

         forms:
           {form_name}:
             required_slots: []
-        """
-    )
+        """)
 
     policy.train([GREET_RULE], domain)
 

tests/core/policies/test_rule_policy.py~L888

 async def test_predict_loop_action_if_in_loop_but_there_is_e2e_rule(policy: RulePolicy):
     loop_name = "some_loop"
 
-    domain = Domain.from_yaml(
-        f"""
+    domain = Domain.from_yaml(f"""
         version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
         intents:
         - {GREET_INTENT_NAME}

tests/core/policies/test_rule_policy.py~L904

         forms:
           {loop_name}:
             required_slots: []
-        """
-    )
+        """)
     e2e_rule = TrackerWithCachedStates.from_events(
         "bla",
         domain=domain,

tests/core/policies/test_rule_policy.py~L944

 async def test_predict_form_action_if_multiple_turns(policy: RulePolicy):
     form_name = "some_form"
     other_intent = "bye"
-    domain = Domain.from_yaml(
-        f"""
+    domain = Domain.from_yaml(f"""
         version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
         intents:
         - {GREET_INTENT_NAME}

tests/core/policies/test_rule_policy.py~L961

         forms:
           {form_name}:
             required_slots: []
-        """
-    )
+        """)
 
     policy.train([GREET_RULE], domain)
 

tests/core/policies/test_rule_policy.py~L994

 
 
 async def test_predict_slot_initial_value_not_required_in_rule(policy: RulePolicy):
-    domain = Domain.from_yaml(
-        """
+    domain = Domain.from_yaml("""
 intents:
 - i1
 actions:

tests/core/policies/test_rule_policy.py~L1009

     initial_value: v1
     mappings:
     - type: from_text
-"""
-    )
+""")
 
     rule = DialogueStateTracker.from_events(
         "slot rule",

tests/core/policies/test_rule_policy.py~L1044

 
 
 async def test_predict_slot_with_initial_slot_matches_rule(policy: RulePolicy):
-    domain = Domain.from_yaml(
-        """
+    domain = Domain.from_yaml("""
 intents:
 - i1
 actions:

tests/core/policies/test_rule_policy.py~L1059

     initial_value: v1
     mappings:
     - type: from_text
-"""
-    )
+""")
 
     rule = DialogueStateTracker.from_events(
         "slot rule",

tests/core/policies/test_rule_policy.py~L1093

 async def test_predict_action_listen_after_form(policy: RulePolicy):
     form_name = "some_form"
 
-    domain = Domain.from_yaml(
-        f"""
+    domain = Domain.from_yaml(f"""
         version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
         intents:
         - {GREET_INTENT_NAME}

tests/core/policies/test_rule_policy.py~L1109

         forms:
           {form_name}:
             required_slots: []
-        """
-    )
+        """)
 
     policy.train([GREET_RULE], domain)
 

tests/core/policies/test_rule_policy.py~L1140

 async def test_dont_predict_form_if_already_finished(policy: RulePolicy):
     form_name = "some_form"
 
-    domain = Domain.from_yaml(
-        f"""
+    domain = Domain.from_yaml(f"""
         version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
         intents:
         - {GREET_INTENT_NAME}

tests/core/policies/test_rule_policy.py~L1156

         forms:
           {form_name}:
             required_slots: []
-        """
-    )
+        """)
 
     policy.train([GREET_RULE], domain)
 

tests/core/policies/test_rule_policy.py~L1191

 async def test_form_unhappy_path(policy: RulePolicy):
     form_name = "some_form"
 
-    domain = Domain.from_yaml(
-        f"""
+    domain = Domain.from_yaml(f"""
         version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
         intents:
         - {GREET_INTENT_NAME}

tests/core/policies/test_rule_policy.py~L1207

         forms:
           {form_name}:
             required_slots: []
-        """
-    )
+        """)
 
     policy.train([GREET_RULE], domain)
 

tests/core/policies/test_rule_policy.py~L1236

 async def test_form_unhappy_path_from_general_rule(policy: RulePolicy):
     form_name = "some_form"
 
-    domain = Domain.from_yaml(
-        f"""
+    domain = Domain.from_yaml(f"""
         version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
         intents:
         - {GREET_INTENT_NAME}

tests/core/policies/test_rule_policy.py~L1252

         forms:
           {form_name}:
             required_slots: []
-        """
-    )
+        """)
 
     # RulePolicy should memorize that unhappy_rule overrides GREET_RULE
     policy.train([GREET_RULE], domain)

tests/core/policies/test_rule_policy.py~L1293

     form_name = "some_form"
     handle_rejection_action_name = "utter_handle_rejection"
 
-    domain = Domain.from_yaml(
-        f"""
+    domain = Domain.from_yaml(f"""
         version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
         intents:
         - {GREET_INTENT_NAME}

tests/core/policies/test_rule_policy.py~L1310

         forms:
           {form_name}:
             required_slots: []
-        """
-    )
+        """)
 
     unhappy_rule = TrackerWithCachedStates.from_events(
         "bla",

tests/core/policies/test_rule_policy.py~L1369

     form_name = "some_form"
     handle_rejection_action_name = "utter_handle_rejection"
 
-    domain = Domain.from_yaml(
-        f"""
+    domain = Domain.from_yaml(f"""
         version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
         intents:
         - {GREET_INTENT_NAME}

tests/core/policies/test_rule_policy.py~L1386

         forms:
           {form_name}:
             required_slots: []
-        """
-    )
+        """)
 
     unhappy_story = TrackerWithCachedStates.from_events(
         "bla",

tests/core/policies/test_rule_policy.py~L1446

     form_name = "some_form"
     handle_rejection_action_name = "utter_handle_rejection"
 
-    domain = Domain.from_yaml(
-        f"""
+    domain = Domain.from_yaml(f"""
         version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
         intents:
         - {GREET_INTENT_NAME}

tests/core/policies/test_rule_policy.py~L1463

         forms:
           {form_name}:
             required_slots: []
-        """
-    )
+        """)
 
     unhappy_rule = TrackerWithCachedStates.from_events(
         "bla",

tests/core/policies/test_rule_policy.py~L1537

     form_name = "some_form"
     handle_rejection_action_name = "utter_handle_rejection"
 
-    domain = Domain.from_yaml(
-        f"""
+    domain = Domain.from_yaml(f"""
         version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
         intents:
         - {GREET_INTENT_NAME}

tests/core/policies/test_rule_policy.py~L1554

         forms:
           {form_name}:
             required_slots: []
-        """
-    )
+        """)
 
     unhappy_story = TrackerWithCachedStates.from_events(
         "bla",

tests/core/policies/test_rule_policy.py~L1607

 async def test_form_unhappy_path_without_rule(policy: RulePolicy):
     form_name = "some_form"
     other_intent = "bye"
-    domain = Domain.from_yaml(
-        f"""
+    domain = Domain.from_yaml(f"""
         version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
         intents:
         - {GREET_INTENT_NAME}

tests/core/policies/test_rule_policy.py~L1624

         forms:
           {form_name}:
             required_slots: []
-        """
-    )
+        """)
 
     policy.train([GREET_RULE], domain)
 

tests/core/policies/test_rule_policy.py~L1653

 async def test_form_activation_rule(policy: RulePolicy):
     form_name = "some_form"
     other_intent = "bye"
-    domain = Domain.from_yaml(
-        f"""
+    domain = Domain.from_yaml(f"""
         version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
         intents:
         - {GREET_INTENT_NAME}

tests/core/policies/test_rule_policy.py~L1670

         forms:
           {form_name}:
             required_slots: []
-        """
-    )
+        """)
 
     form_activation_rule = _form_activation_rule(domain, form_name, other_intent)
     policy.train([GREET_RULE, form_activation_rule], domain)

tests/core/policies/test_rule_policy.py~L1694

 async def test_failing_form_activation_due_to_no_rule(policy: RulePolicy):
     form_name = "some_form"
     other_intent = "bye"
-    domain = Domain.from_yaml(
-        f"""
+    domain = Domain.from_yaml(f"""
         version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
         intents:
         - {GREET_INTENT_NAME}

tests/core/policies/test_rule_policy.py~L1711

         forms:
           {form_name}:
             required_slots: []
-        """
-    )
+        """)
 
     policy.train([GREET_RULE], domain)
 

tests/core/policies/test_rule_policy.py~L1735

 def test_form_submit_rule(policy: RulePolicy):
     form_name = "some_form"
     submit_action_name = "utter_submit"
-    domain = Domain.from_yaml(
-        f"""
+    domain = Domain.from_yaml(f"""
         version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
         intents:
         - {GREET_INTENT_NAME}

tests/core/policies/test_rule_policy.py~L1752

         forms:
           {form_name}:
             required_slots: []
-        """
-    )
+        """)
 
     form_submit_rule = _form_submit_rule(domain, submit_action_name, form_name)
 

tests/core/policies/test_rule_policy.py~L1789

     submit_action_name = "utter_submit"
     entity = "some_entity"
     slot = "some_slot"
-    domain = Domain.from_yaml(
-        f"""
+    domain = Domain.from_yaml(f"""
         version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
         intents:
         - {GREET_INTENT_NAME}

tests/core/policies/test_rule_policy.py~L1812

             required_slots: []
         entities:
         - {entity}
-        """
-    )
+        """)
 
     form_activation_rule = _form_activation_rule(domain, form_name, GREET_INTENT_NAME)
     form_submit_rule = _form_submit_rule(domain, submit_action_name, form_name)

tests/core/policies/test_rule_policy.py~L1895

 
 
 async def test_one_stage_fallback_rule(policy: RulePolicy):
-    domain = Domain.from_yaml(
-        f"""
+    domain = Domain.from_yaml(f"""
         version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
         intents:
         - {GREET_INTENT_NAME}
         - {DEFAULT_NLU_FALLBACK_INTENT_NAME}
         actions:
         - {UTTER_GREET_ACTION}
-        """
-    )
+        """)
 
     fallback_recover_rule = TrackerWithCachedStates.from_events(
         "bla",

tests/core/policies/test_rule_policy.py~L1978

 def test_default_actions(
     intent_name: Text, expected_action_name: Text, policy: RulePolicy
 ):
-    domain = Domain.from_yaml(
-        f"""
+    domain = Domain.from_yaml(f"""
         version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
         intents:
         - {GREET_INTENT_NAME}
         actions:
         - {UTTER_GREET_ACTION}
-        """
-    )
+        """)
     policy.train([GREET_RULE], domain)
     new_conversation = DialogueStateTracker.from_events(
         "bla2",

tests/core/policies/test_rule_policy.py~L2006

     "intent_name", [USER_INTENT_RESTART, USER_INTENT_BACK, USER_INTENT_SESSION_START]
 )
 def test_e2e_beats_default_actions(intent_name: Text, policy: RulePolicy):
-    domain = Domain.from_yaml(
-        f"""
+    domain = Domain.from_yaml(f"""
         version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
         intents:
         - {GREET_INTENT_NAME}
         actions:
         - {UTTER_GREET_ACTION}
-        """
-    )
+        """)
 
     e2e_rule = TrackerWithCachedStates.from_events(
         "bla",

tests/core/policies/test_rule_policy.py~L2067

     expected_prediction: Text,
 ):
     other_intent = "other"
-    domain = Domain.from_yaml(
-        f"""
+    domain = Domain.from_yaml(f"""
         version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
         intents:
         - {GREET_INTENT_NAME}

tests/core/policies/test_rule_policy.py~L2076

         actions:
         - {UTTER_GREET_ACTION}
         - my_core_fallback
-        """
-    )
+        """)
     rule_policy = policy_with_config(config)
     rule_policy.train([GREET_RULE], domain)
 

tests/core/policies/test_rule_policy.py~L2100

     policy_with_config: Callable[..., RulePolicy],
 ):
     other_intent = "other"
-    domain = Domain.from_yaml(
-        f"""
+    domain = Domain.from_yaml(f"""
         version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
         intents:
         - {GREET_INTENT_NAME}
         - {other_intent}
         actions:
         - {UTTER_GREET_ACTION}
-        """
-    )
+        """)
     policy = policy_with_config({"enable_fallback_prediction": False})
     policy.train([GREET_RULE], domain)
     new_conversation = DialogueStateTracker.from_events(

tests/core/policies/test_rule_policy.py~L2127

 def test_hide_rule_turn(policy: RulePolicy):
     chitchat = "chitchat"
     action_chitchat = "action_chitchat"
-    domain = Domain.from_yaml(
-        f"""
+    domain = Domain.from_yaml(f"""
         version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
         intents:
         - {GREET_INTENT_NAME}

tests/core/policies/test_rule_policy.py~L2136

         actions:
         - {UTTER_GREET_ACTION}
         - {action_chitchat}
-        """
-    )
+        """)
     chitchat_story = TrackerWithCachedStates.from_events(
         "chitchat story",
         domain=domain,

tests/core/policies/test_rule_policy.py~L2207

     some_slot_value = "value1"
     slot_which_is_also_in_story = "slot_which_is_also_in_story"
     some_other_slot_value = "value2"
-    domain = Domain.from_yaml(
-        f"""
+    domain = Domain.from_yaml(f"""
         version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
         intents:
         - {some_intent}

tests/core/policies/test_rule_policy.py~L2225

             type: text
             mappings:
             - type: from_text
-        """
-    )
+        """)
 
     simple_rule = TrackerWithCachedStates.from_events(
         "simple rule with an action that sets 1 slot",

tests/core/policies/test_rule_policy.py~L2334

     chitchat = "chitchat"
     action_chitchat = "action_chitchat"
     followup_on_chitchat = "followup_on_chitchat"
-    domain = Domain.from_yaml(
-        f"""
+    domain = Domain.from_yaml(f"""
         version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
         intents:
         - {chitchat}

tests/core/policies/test_rule_policy.py~L2347

             type: bool
             mappings:
             - type: from_text
-        """
-    )
+        """)
     simple_rule_no_last_action_listen = TrackerWithCachedStates.from_events(
         "simple rule without action listen in the end",
         domain=domain,

tests/core/policies/test_rule_policy.py~L2422

     activate_another_form = "activate_another_form"
     chitchat = "chitchat"
     action_chitchat = "action_chitchat"
-    domain = Domain.from_yaml(
-        f"""
+    domain = Domain.from_yaml(f"""
         version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
         intents:
         - {GREET_INTENT_NAME}

tests/core/policies/test_rule_policy.py~L2443

             required_slots: []
           {another_form_name}:
             required_slots: []
-        """
-    )
+        """)
 
     form_activation_rule = _form_activation_rule(domain, form_name, activate_form)
 

tests/core/policies/test_rule_policy.py~L2530

 def test_do_not_hide_rule_turn_with_loops_in_stories(policy: RulePolicy):
     form_name = "some_form"
     activate_form = "activate_form"
-    domain = Domain.from_yaml(
-        f"""
+    domain = Domain.from_yaml(f"""
         version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
         intents:
         - {activate_form}

tests/core/policies/test_rule_policy.py~L2543

         forms:
           {form_name}:
             required_slots: []
-        """
-    )
+        """)
 
     form_activation_rule = _form_activation_rule(domain, form_name, activate_form)
     form_activation_story = form_activation_rule.copy()

tests/core/policies/test_rule_policy.py~L2585

 def test_hide_rule_turn_with_loops_as_followup_action(policy: RulePolicy):
     form_name = "some_form"
     activate_form = "activate_form"
-    domain = Domain.from_yaml(
-        f"""
+    domain = Domain.from_yaml(f"""
         version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
         intents:
         - {GREET_INTENT_NAME}

tests/core/policies/test_rule_policy.py~L2601

         forms:
           {form_name}:
             required_slots: []
-        """
-    )
+        """)
 
     form_activation_rule = _form_activation_rule(domain, form_name, activate_form)
     form_activation_story = form_activation_rule.copy()

tests/core/policies/test_rule_policy.py~L2689

     intent_1 = "intent_1"
     utter_1 = "utter_1"
     utter_2 = "utter_2"
-    domain = Domain.from_yaml(
-        f"""
+    domain = Domain.from_yaml(f"""
         version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
         intents:
         - {intent_1}
         actions:
         - {utter_1}
         - {utter_2}
-        """
-    )
+        """)
     rule = TrackerWithCachedStates.from_events(
         "conditioned on action",
         domain=domain,

tests/core/policies/test_rule_policy.py~L2734

     utter_1 = "utter_1"
     utter_2 = "utter_2"
     utter_3 = "utter_3"
-    domain = Domain.from_yaml(
-        f"""
+    domain = Domain.from_yaml(f"""
         version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
         intents:
         - {intent_1}

tests/core/policies/test_rule_policy.py~L2743

         - {utter_1}
         - {utter_2}
         - {utter_3}
-        """
-    )
+        """)
     rule = TrackerWithCachedStates.from_events(
         "action_listen after predictable action",
         domain=domain,

tests/core/policies/test_rule_policy.py~L2780

     intent_1 = "intent_1"
     utter_1 = "utter_1"
     utter_2 = "utter_2"
-    domain = Domain.from_yaml(
-        f"""
+    domain = Domain.from_yaml(f"""
         version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
         intents:
         - {intent_1}
         actions:
         - {utter_1}
         - {utter_2}
-        """
-    )
+        """)
     rule = TrackerWithCachedStates.from_events(
         "last prediction is action_listen",
         domain=domain,

tests/core/policies/test_rule_policy.py~L2821

     intent_1 = "intent_1"
     utter_1 = "utter_1"
     utter_2 = "utter_2"
-    domain = Domain.from_yaml(
-        f"""
+    domain = Domain.from_yaml(f"""
         version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
         intents:
         - {intent_1}
         actions:
         - {utter_1}
         - {utter_2}
-        """
-    )
+        """)
     rule = TrackerWithCachedStates.from_events(
         "conditioned on action",
         domain=domain,

tests/core/policies/test_rule_policy.py~L2864

     intent_1 = "intent_1"
     utter_1 = "utter_1"
     utter_2 = "utter_2"
-    domain = Domain.from_yaml(
-        f"""
+    domain = Domain.from_yaml(f"""
         version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
         intents:
         - {intent_1}
         actions:
         - {utter_1}
         - {utter_2}
-        """
-    )
+        """)
     rule = TrackerWithCachedStates.from_events(
         "rule without action_listen",
         domain=domain,

tests/core/policies/test_rule_policy.py~L2906

     entity_1 = "entity_1"
     entity_2 = "entity_2"
     utter_1 = "utter_1"
-    domain = Domain.from_yaml(
-        f"""
+    domain = Domain.from_yaml(f"""
         version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
         intents:
         - {intent_1}

tests/core/policies/test_rule_policy.py~L2916

         - {entity_2}
         actions:
         - {utter_1}
-        """
-    )
+        """)
 
     rule = TrackerWithCachedStates.from_events(
         "rule without action_listen",

tests/core/policies/test_rule_policy.py~L2970

     value_2 = "value_2"
     slot_1 = "slot_1"
     slot_2 = "slot_2"
-    domain = Domain.from_yaml(
-        f"""
+    domain = Domain.from_yaml(f"""
             version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
             intents:
             - {intent_1}

tests/core/policies/test_rule_policy.py~L2994

                  - {value_2}
                 mappings:
                 - type: from_text
-            """
-    )
+            """)
     rule = TrackerWithCachedStates.from_events(
         "rule without action_listen",
         domain=domain,

tests/core/policies/test_rule_policy.py~L3038

     value_2 = "value_2"
     slot_1 = "slot_1"
     slot_2 = "slot_2"
-    domain = Domain.from_yaml(
-        f"""
+    domain = Domain.from_yaml(f"""
                 version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
                 intents:
                 - {intent_1}

tests/core/policies/test_rule_policy.py~L3062

                      - {value_2}
                     mappings:
                     - type: from_text
-                """
-    )
+                """)
     rule_1 = TrackerWithCachedStates.from_events(
         "normal rule",
         domain=domain,

tests/core/policies/test_ted_policy.py~L225

         execution_context: ExecutionContext,
     ):
         stories = tmp_path / "stories.yml"
-        stories.write_text(
-            f"""
+        stories.write_text(f"""
             version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
             stories:
             - story: test path
               steps:
               - action: utter_greet
-            """
-        )
+            """)
         policy = self.create_policy(
             featurizer=featurizer,
             model_storage=model_storage,

tests/core/policies/test_unexpected_intent_policy.py~L135

         execution_context: ExecutionContext,
     ):
         stories = tmp_path / "stories.yml"
-        stories.write_text(
-            f"""
+        stories.write_text(f"""
             version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
             stories:
             - story: test path
               steps:
               - action: utter_greet
-            """
-        )
+            """)
         policy = self.create_policy(
             featurizer=featurizer,
             model_storage=model_storage,

tests/core/test_actions.py~L1051

     form_action_name = "my_business_logic"
 
     domain = Domain.from_yaml(
-        textwrap.dedent(
-            f"""
+        textwrap.dedent(f"""
     slots:
       my_slot:
         type: text

tests/core/test_actions.py~L1064

       {form_action_name}:
         {REQUIRED_SLOTS_KEY}:
           {slot}
-    """
-        )
+    """)
     )
 
     actual = action.action_for_name_or_text(form_action_name, domain, None)

tests/core/test_actions.py~L1075

 def test_overridden_form_action():
     form_action_name = "my_business_logic"
     domain = Domain.from_yaml(
-        textwrap.dedent(
-            f"""
+        textwrap.dedent(f"""
     actions:
     - my_action
     - {form_action_name}
     forms:
         {form_action_name}:
           {REQUIRED_SLOTS_KEY}: []
-    """
-        )
+    """)
     )
 
     actual = action.action_for_name_or_text(form_action_name, domain, None)

tests/core/test_actions.py~L1094

 def test_get_form_action_if_not_in_forms():
     form_action_name = "my_business_logic"
     domain = Domain.from_yaml(
-        textwrap.dedent(
-            """
+        textwrap.dedent("""
     actions:
     - my_action
-    """
-        )
+    """)
     )
 
     with pytest.raises(ActionNotFoundException):

tests/core/test_actions.py~L1111

 )
 def test_get_end_to_end_utterance_action(end_to_end_utterance: Text):
     domain = Domain.from_yaml(
-        textwrap.dedent(
-            f"""
+        textwrap.dedent(f"""
     actions:
     - my_action
     {KEY_E2E_ACTIONS}:
     - {end_to_end_utterance}
     - Bye Bye
-"""
-        )
+""")
     )
 
     actual = action.action_for_name_or_text(end_to_end_utterance, domain, None)

tests/core/test_actions.py~L1132

     end_to_end_utterance = "Hi"
 
     domain = Domain.from_yaml(
-        textwrap.dedent(
-            f"""
+        textwrap.dedent(f"""
     actions:
     - my_action
     {KEY_E2E_ACTIONS}:
     - {end_to_end_utterance}
     - Bye Bye
-"""
-        )
+""")
     )
 
     e2e_action = action.action_for_name_or_text("Hi", domain, None)

tests/core/test_actions.py~L1226

     user: Event, slot_name: Text, slot_value: Any, new_user: Event, updated_value: Any
 ):
     domain = Domain.from_yaml(
-        textwrap.dedent(
-            f"""
+        textwrap.dedent(f"""
             version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
             intents:
             - inform

tests/core/test_actions.py~L1266

                 influence_conversation: false
                 mappings:
                 - type: from_entity
-                  entity: name"""
-        )
+                  entity: name""")
     )
 
     action_extract_slots = ActionExtractSlots(action_endpoint=None)

tests/core/test_actions.py~L1309

 
 async def test_action_extract_slots_with_from_trigger_mappings():
     domain = Domain.from_yaml(
-        textwrap.dedent(
-            f"""
+        textwrap.dedent(f"""
             version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
             intents:
             - greet

tests/core/test_actions.py~L1334

             forms:
               registration_form:
                 required_slots:
-                  - email"""
-        )
+                  - email""")
     )
 
     action_extract_slots = ActionExtractSlots(action_endpoint=None)

tests/core/test_actions.py~L1428

     slot_name = "toppings"
 
     domain = Domain.from_yaml(
-        textwrap.dedent(
-            f"""
+        textwrap.dedent(f"""
     version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
 
     entities:

tests/core/test_actions.py~L1447

       {form_name}:
         {REQUIRED_SLOTS_KEY}:
           - {slot_name}
-    """
-        )
+    """)
     )
 
     tracker = DialogueStateTracker.from_events(

tests/core/test_actions.py~L1525

     form_name = "some_form"
 
     domain = Domain.from_yaml(
-        textwrap.dedent(
-            f"""
+        textwrap.dedent(f"""
             version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
             intent:
             - greet

tests/core/test_actions.py~L1548

              other_form:
                required_slots:
                  - name
-            """
-        )
+            """)
     )
 
     tracker = DialogueStateTracker.from_events(

tests/core/test_actions.py~L1578

     form_name = "some_form"
 
     domain = Domain.from_yaml(
-        textwrap.dedent(
-            f"""
+        textwrap.dedent(f"""
             version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
             intent:
             - greet

tests/core/test_actions.py~L1608

                required_slots:
                  - email
                  - name
-            """
-        )
+            """)
     )
 
     tracker = DialogueStateTracker.from_events(

tests/core/test_actions.py~L1819

     form_name = "some_form"
     slot_name = "toppings"
     domain = Domain.from_yaml(
-        textwrap.dedent(
-            f"""
+        textwrap.dedent(f"""
     version: "{LATEST_TRAINING_DATA_FORMAT_VERSION}"
 
     entities:

tests/core/test_actions.py~L1843

       {form_name}:
         {REQUIRED_SLOTS_KEY}:
           - {slot_name}
-    """
-        )
+    """)
     )
 
     tracker = DialogueStateTracker.from_events(

tests/core/test_actions.py~L2031

     validate_return_events: List[Dict[Tex...*[Comment body truncated]*

@MichaReiser MichaReiser marked this pull request as ready for review December 22, 2023 09:52
@MichaReiser

This comment was marked as outdated.

@charliermarsh

This comment was marked as outdated.

@MichaReiser

This comment was marked as outdated.

@MichaReiser

This comment was marked as resolved.

@MichaReiser MichaReiser marked this pull request as draft January 8, 2024 17:03
@MichaReiser
Copy link
Member Author

I plan to make changes to this implementation.

@MichaReiser MichaReiser force-pushed the multiline-string branch 2 times, most recently from 8968a35 to fab614e Compare January 9, 2024 09:58
@MichaReiser
Copy link
Member Author

MichaReiser commented Jan 9, 2024

The stable style formatting changes now match Black's stable formatting. We can consider it a bugfix.

@@ -1493,7 +1498,13 @@ impl<'a, 'print> FitsMeasurer<'a, 'print> {
return Fits::No;
}
match args.measure_mode() {
MeasureMode::FirstLine => return Fits::Yes,
MeasureMode::FirstLine => {
return if exceeds_width(self, args) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bug fix in the printer. So far, it always returned Fits::Yes if a text contained a newline character regardless if the text before the newline exceeded the line width. This was incorrect.

@MichaReiser MichaReiser requested a review from konstin January 9, 2024 11:04
@MichaReiser MichaReiser marked this pull request as ready for review January 9, 2024 11:04
@MichaReiser
Copy link
Member Author

@charliermarsh or @konstin I changed the implementation quiet significantly. It would be great to get a second review.

@MichaReiser MichaReiser merged commit ac02d3a into main Jan 10, 2024
17 checks passed
@MichaReiser MichaReiser deleted the multiline-string branch January 10, 2024 11:47
@T-256
Copy link
Contributor

T-256 commented Jan 10, 2024

cc @zanieb
Are diffs now show correct before/after? I think they are reversed.
I checked source links of diffs, and it seems what it shows as added lines, already exist at source.

Formatter (stable)

ℹ️ ecosystem check detected format changes. (+5 -6 lines in 2 files in 2 projects; 41 projects unchanged)

demisto/content (+2 -5 lines across 1 file)
ruff format --no-preview --exclude Packs/ThreatQ/Integrations/ThreatQ/ThreatQ.py
Packs/IntegrationsAndIncidentsHealthCheck/Scripts/GetFailedTasks/GetFailedTasks.py~L107

     )
 
     if is_error(response):
-        error = (
-            f'Failed retrieving tasks for incident ID {incident["id"]}.\n \
+        error = f'Failed retrieving tasks for incident ID {incident["id"]}.\n \
            Make sure that the API key configured in the Core REST API integration \
-is one with sufficient permissions to access that incident.\n'
-            + get_error(response)
-        )
+is one with sufficient permissions to access that incident.\n' + get_error(response)
         raise Exception(error)
 
     return response[0]["Contents"]["response"]

reflex-dev/reflex (+3 -1 lines across 1 file)
reflex/components/markdown/markdown.py~L259

         }
 
         # Separate out inline code and code blocks.
-        components["code"] = f"""{{({{node, inline, className, {_CHILDREN._var_name}, {_PROPS._var_name}}}) => {{
+        components[
+            "code"
+        ] = f"""{{({{node, inline, className, {_CHILDREN._var_name}, {_PROPS._var_name}}}) => {{
     const match = (className || '').match(/language-(?<lang>.*)/);
     const language = match ? match[1] : '';
     if (language) {{

@MichaReiser
Copy link
Member Author

@T-256 The diff shows that the old version (main) used to parenthesize f'Failed... and the new version (this PR) removes the parentheses around it.

The diff isn't showing the difference to the commit version in Git because some projects in our ecosystem check may not use Ruff formatter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
formatter Related to the formatter preview Related to preview mode features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Formatter: multiline_string_handling preview style
4 participants