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

Enable flake8 code E501 #8680

Merged
merged 23 commits into from
Jun 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
80e2f15
Fix all E501 code alerts
iurisevero May 12, 2021
81a88e9
Merge branch 'main' of git://github.com/RasaHQ/rasa into 8490-Enable-…
iurisevero May 13, 2021
d75fbd8
Fix tests and new E501 errors
iurisevero May 13, 2021
2c34e80
Fix docstrings errors
iurisevero May 13, 2021
fb90f9c
Fix convert_featurizer test error
iurisevero May 13, 2021
c1a5d71
Update rasa/core/tracker_store.py
iurisevero May 17, 2021
b7a9fd3
Update rasa/nlu/featurizers/dense_featurizer/convert_featurizer.py
iurisevero May 17, 2021
d94cd06
Update rasa/nlu/featurizers/dense_featurizer/convert_featurizer.py
iurisevero May 17, 2021
98dcb3f
Update rasa/nlu/featurizers/dense_featurizer/convert_featurizer.py
iurisevero May 17, 2021
b7e9c21
Update rasa/nlu/featurizers/dense_featurizer/convert_featurizer.py
iurisevero May 17, 2021
5c3e514
Update rasa/nlu/featurizers/dense_featurizer/convert_featurizer.py
iurisevero May 17, 2021
7b41cb2
Update imports, fix convert featurizer tests
iurisevero May 17, 2021
9dbfced
Merge branch 'main' into 8490-Enable-flake8-code-E501
iurisevero May 17, 2021
ba1c8d6
Merge branch 'main' into 8490-Enable-flake8-code-E501
iurisevero May 18, 2021
0ae10fe
Fix validator.py and test_validator.py lint and remove per-file-ignor…
iurisevero May 18, 2021
00a09a4
Update rasa/nlu/featurizers/dense_featurizer/convert_featurizer.py
iurisevero May 26, 2021
8f28bcc
Update tests/nlu/featurizers/test_convert_featurizer.py
iurisevero May 26, 2021
562eef0
Resolve conversations
iurisevero May 27, 2021
6500bcb
Merge branch 'main' of git://github.com/RasaHQ/rasa into 8490-Enable-…
iurisevero May 27, 2021
e2ce61f
Fix lint appointments
iurisevero May 27, 2021
56c4f21
Merge branch 'main' into 8490-Enable-flake8-code-E501
iurisevero May 28, 2021
2cb9dcf
Merge branch 'main' into 8490-Enable-flake8-code-E501
iurisevero Jun 3, 2021
87a1089
Merge branch 'main' into 8490-Enable-flake8-code-E501
iurisevero Jun 3, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion rasa/cli/arguments/interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ def _add_common_params(parser: argparse.ArgumentParser) -> None:

rasa.cli.arguments.default_arguments.add_endpoint_param(
parser,
help_text="Configuration file for the model server and the connectors as a yml file.",
help_text="Configuration file for the model server "
"and the connectors as a yml file.",
)


Expand Down
3 changes: 2 additions & 1 deletion rasa/cli/arguments/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ def add_server_arguments(parser: argparse.ArgumentParser) -> None:
)
server_arguments.add_argument(
"--ssl-ca-file",
help="If your SSL certificate needs to be verified, you can specify the CA file "
help="If your SSL certificate needs to be verified, "
"you can specify the CA file "
"using this parameter.",
)
server_arguments.add_argument(
Expand Down
4 changes: 2 additions & 2 deletions rasa/cli/arguments/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ def add_test_core_model_param(parser: argparse.ArgumentParser) -> None:
default=[default_path],
help="Path to a pre-trained model. If it is a 'tar.gz' file that model file "
"will be used. If it is a directory, the latest model in that directory "
"will be used (exception: '--evaluate-model-directory' flag is set). If multiple "
"'tar.gz' files are provided, all those models will be compared.",
"will be used (exception: '--evaluate-model-directory' flag is set). "
"If multiple 'tar.gz' files are provided, all those models will be compared.",
)


Expand Down
3 changes: 2 additions & 1 deletion rasa/cli/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,8 @@ def _validate_story_structure(validator: "Validator", args: argparse.Namespace)
# Check if a valid setting for `max_history` was given
if isinstance(args.max_history, int) and args.max_history < 1:
raise argparse.ArgumentTypeError(
f"The value of `--max-history {args.max_history}` is not a positive integer."
f"The value of `--max-history {args.max_history}` "
f"is not a positive integer."
)

return validator.verify_story_structure(
Expand Down
3 changes: 2 additions & 1 deletion rasa/cli/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ def run_core_test(args: argparse.Namespace) -> None:

if args.model is None:
rasa.shared.utils.cli.print_error(
"No model provided. Please make sure to specify the model to test with '--model'."
"No model provided. Please make sure to specify "
"the model to test with '--model'."
)
return

Expand Down
3 changes: 2 additions & 1 deletion rasa/core/actions/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,8 @@ async def _utter_responses(
"'response', use the `response` parameter instead of "
"`template` in `dispatcher.utter_message`. You can do that "
"by upgrading to Rasa SDK 2.4.1 or adapting your custom SDK.",
docs=f"{rasa.shared.constants.DOCS_BASE_URL_ACTION_SERVER}/sdk-dispatcher",
docs=f"{rasa.shared.constants.DOCS_BASE_URL_ACTION_SERVER}"
f"/sdk-dispatcher",
)
if generated_response:
draft = await nlg.generate(
Expand Down
3 changes: 2 additions & 1 deletion rasa/core/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,8 @@ def update_model(

if hasattr(self.nlg, "templates"):
rasa.shared.utils.io.raise_deprecation_warning(
"Please use the `responses` attribute instead of the `templates` attribute to manage responses.",
"Please use the `responses` attribute instead of the `templates` "
"attribute to manage responses.",
docs=f"{DOCS_URL_MIGRATION_GUIDE}#rasa-23-to-rasa-24",
)
self.nlg.templates = domain.responses if domain else {}
Expand Down
3 changes: 2 additions & 1 deletion rasa/core/brokers/pika.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ async def connect(self) -> None:

channel = await self._connection.channel()
logger.debug(
f"RabbitMQ channel was opened. Declaring fanout exchange '{self.exchange_name}'."
f"RabbitMQ channel was opened. "
f"Declaring fanout exchange '{self.exchange_name}'."
)

self._exchange = await self._set_up_exchange(channel)
Expand Down
11 changes: 9 additions & 2 deletions rasa/core/channels/hangouts.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,22 @@
logger = logging.getLogger(__name__)

CHANNEL_NAME = "hangouts"
CERT_URI = "https://www.googleapis.com/service_accounts/v1/metadata/x509/[email protected]"
CERT_URI = (
"https://www.googleapis.com/service_accounts/"
"v1/metadata/x509/[email protected]"
)


class HangoutsOutput(OutputChannel):
"""A Hangouts communication channel."""

@classmethod
def name(cls) -> Text:
"""Return channel name."""
return CHANNEL_NAME

def __init__(self) -> None:
"""Starts messages as empty dictionary."""
self.messages = {}

@staticmethod
Expand Down Expand Up @@ -247,7 +254,7 @@ def _extract_input_channel(self) -> Text:
return self.name()

def _check_token(self, bot_token: Text) -> None:
# see https://developers.google.com/hangouts/chat/how-tos/bots-develop#verifying_bot_authenticity # noqa: W505
# see https://developers.google.com/hangouts/chat/how-tos/bots-develop#verifying_bot_authenticity # noqa: E501, W505
try:
token = client.verify_id_token(
bot_token, self.project_id, cert_uri=CERT_URI
Expand Down
2 changes: 1 addition & 1 deletion rasa/core/channels/mattermost.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ async def send_text_with_buttons(
) -> None:
"""Sends buttons to the output."""
# buttons are a list of objects: [(option_name, payload)]
# See https://docs.mattermost.com/developer/interactive-messages.html#message-buttons # noqa: W505
# See https://docs.mattermost.com/developer/interactive-messages.html#message-buttons # noqa: E501, W505

actions = [
{
Expand Down
8 changes: 5 additions & 3 deletions rasa/core/channels/slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,9 @@ def _is_interactive_message(payload: Dict) -> bool:
return True
elif action_type:
logger.warning(
"Received input from a Slack interactive component of type "
f"'{payload['actions'][0]['type']}', for which payload parsing is not yet supported."
f"Received input from a Slack interactive component of type "
f"'{payload['actions'][0]['type']}', "
f"for which payload parsing is not yet supported."
)
return False

Expand Down Expand Up @@ -517,7 +518,8 @@ async def webhook(request: Request) -> HTTPResponse:

if not self._is_supported_channel(output, metadata):
logger.warning(
f"Received message on unsupported channel: {metadata['out_channel']}"
f"Received message on unsupported "
f"channel: {metadata['out_channel']}"
)
return response.text("channel not supported.")

Expand Down
32 changes: 19 additions & 13 deletions rasa/core/channels/twilio_voice.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,10 @@ def _validate_configuration(self) -> None:
def _raise_invalid_speech_model_timeout_exception(self) -> None:
"""Raises an error if incompatible speech_timeout and speech_model used."""
raise InvalidConfigException(
"If speech_timeout is 'auto' the speech_model must be 'numbers_and_commands'. Please update your "
"speech_model to be 'numbers_and_commands' if you would like to continue using the 'auto' speech_model."
"If speech_timeout is 'auto' the speech_model must be "
"'numbers_and_commands'. Please update your speech_model "
"to be 'numbers_and_commands' if you would like to continue "
"using the 'auto' speech_model."
)

def _raise_invalid_enhanced_option_exception(self) -> None:
Expand All @@ -184,8 +186,9 @@ def _raise_invalid_speech_model_exception(self) -> None:
"""Raises an error if an invalid speech_model is provided."""
raise InvalidConfigException(
f"The value {self.speech_model} for speech_model is invalid. "
f"You must choose one of 'default', 'numbers_and_commands', or 'phone_call'. "
f"Refer to the documentation for details about the selections."
f"You must choose one of 'default', 'numbers_and_commands', "
f"or 'phone_call'. Refer to the documentation for details "
f"about the selections."
)

def _raise_invalid_speech_timeout_exception(self) -> None:
Expand All @@ -199,15 +202,15 @@ def _raise_invalid_voice_exception(self) -> None:
"""Raises an error if an invalid voice is provided."""
raise InvalidConfigException(
f"The value {self.assistant_voice} is an invalid for assistant_voice. "
f"Please refer to the documentation for a list of valid voices you can use for "
f"your voice assistant."
f"Please refer to the documentation for a list of valid voices "
f"you can use for your voice assistant."
)

def _raise_invalid_enhanced_speech_model_exception(self) -> None:
"""Raises error if enhanced is used with an incompatible speech_model."""
raise InvalidConfigException(
f"If you set enhanced to 'true' then speech_model must be 'phone_call'. Current speech_model is: "
f"{self.speech_model}."
f"If you set enhanced to 'true' then speech_model must be 'phone_call'. "
f"Current speech_model is: {self.speech_model}."
)

def blueprint(
Expand Down Expand Up @@ -315,8 +318,8 @@ def _emoji_warning(text: Text,) -> None:
emoji_regex = rasa.utils.io.get_emoji_regex()
if emoji_regex.findall(text):
rasa.shared.utils.io.raise_warning(
"Text contains an emoji in a voice response. Review responses to provide a voice-friendly "
"alternative."
"Text contains an emoji in a voice response. "
"Review responses to provide a voice-friendly alternative."
)

async def send_text_message(
Expand Down Expand Up @@ -347,7 +350,10 @@ async def send_image_url(
) -> None:
"""For voice channel do not send images."""
rasa.shared.utils.io.raise_warning(
"An image was removed from the voice message and only the text of message was sent. "
"It's recommended that you define voice-friendly alternatives for all responses "
"with a visual elements such as images and emojis that are used in your voice channel."
"An image was removed from the voice message and "
"only the text of message was sent. "
"It's recommended that you define voice-friendly "
"alternatives for all responses "
"with a visual elements such as images and emojis "
"that are used in your voice channel."
)
3 changes: 2 additions & 1 deletion rasa/core/featurizers/tracker_featurizers.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ def training_states_actions_and_entities(
A tuple of list of states, list of actions and list of entity data.
"""
raise NotImplementedError(
f"`{self.__class__.__name__}` should implement how to encode trackers as feature vectors"
f"`{self.__class__.__name__}` should implement how to "
f"encode trackers as feature vectors"
)

def training_states_and_actions(
Expand Down
3 changes: 2 additions & 1 deletion rasa/core/lock_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,8 @@ def _set_key_prefix(self, key_prefix: Text) -> None:
self.key_prefix = key_prefix + ":" + DEFAULT_REDIS_LOCK_STORE_KEY_PREFIX
else:
logger.warning(
f"Omitting provided non-alphanumeric redis key prefix: '{key_prefix}'. Using default '{self.key_prefix}' instead."
f"Omitting provided non-alphanumeric redis key prefix: '{key_prefix}'. "
f"Using default '{self.key_prefix}' instead."
)

def get_lock(self, conversation_id: Text) -> Optional[TicketLock]:
Expand Down
15 changes: 5 additions & 10 deletions rasa/core/policies/ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
from rasa.core.policies.fallback import FallbackPolicy
from rasa.core.policies.memoization import MemoizationPolicy, AugmentedMemoizationPolicy
from rasa.core.policies.rule_policy import RulePolicy
from rasa.core.training import training
from rasa.shared.core.trackers import DialogueStateTracker
from rasa.shared.core.generator import TrackerWithCachedStates
from rasa.core import registry
Expand Down Expand Up @@ -167,14 +168,11 @@ def _emit_rule_policy_warning(
is_rules_consuming_policy_available = (
self._policy_ensemble_contains_policy_with_rules_support()
)
training_trackers_contain_rule_trackers = self._training_trackers_contain_rule_trackers(
contain_rule_trackers = self._training_trackers_contain_rule_trackers(
training_trackers
)

if (
is_rules_consuming_policy_available
and not training_trackers_contain_rule_trackers
):
if is_rules_consuming_policy_available and not contain_rule_trackers:
rasa.shared.utils.io.raise_warning(
f"Found a rule-based policy in your pipeline but "
f"no rule-based training data. Please add rule-based "
Expand All @@ -183,10 +181,7 @@ def _emit_rule_policy_warning(
f"your pipeline.",
docs=DOCS_URL_RULES,
)
elif (
not is_rules_consuming_policy_available
and training_trackers_contain_rule_trackers
):
elif not is_rules_consuming_policy_available and contain_rule_trackers:
rasa.shared.utils.io.raise_warning(
f"Found rule-based training data but no policy supporting rule-based "
f"data. Please add `{RulePolicy.__name__}` or another rule-supporting "
Expand All @@ -212,7 +207,7 @@ def train(
trackers_to_train, domain, interpreter=interpreter, **kwargs
)

self.action_fingerprints = rasa.core.training.training.create_action_fingerprints(
self.action_fingerprints = training.create_action_fingerprints(
training_trackers, domain
)
# set rule only data after training in order to make ensemble usable
Expand Down
6 changes: 4 additions & 2 deletions rasa/core/policies/policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,11 +447,13 @@ def format_tracker_states(states: List[Dict]) -> Text:
if PREVIOUS_ACTION in state:
if ACTION_NAME in state[PREVIOUS_ACTION]:
state_messages.append(
f"previous action name: {str(state[PREVIOUS_ACTION][ACTION_NAME])}"
f"previous action name: "
f"{str(state[PREVIOUS_ACTION][ACTION_NAME])}"
)
if ACTION_TEXT in state[PREVIOUS_ACTION]:
state_messages.append(
f"previous action text: {str(state[PREVIOUS_ACTION][ACTION_TEXT])}"
f"previous action text: "
f"{str(state[PREVIOUS_ACTION][ACTION_TEXT])}"
)
if ACTIVE_LOOP in state:
state_messages.append(f"active loop: {str(state[ACTIVE_LOOP])}")
Expand Down
3 changes: 2 additions & 1 deletion rasa/core/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ def serve_application(
protocol = "https" if ssl_context else "http"

logger.info(
f"Starting Rasa server on {constants.DEFAULT_SERVER_FORMAT.format(protocol, port)}"
f"Starting Rasa server on "
f"{constants.DEFAULT_SERVER_FORMAT.format(protocol, port)}"
)

app.register_listener(
Expand Down
7 changes: 5 additions & 2 deletions rasa/core/tracker_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,8 @@ def _set_key_prefix(self, key_prefix: Text) -> None:
self.key_prefix = key_prefix + ":" + DEFAULT_REDIS_TRACKER_STORE_KEY_PREFIX
else:
logger.warning(
f"Omitting provided non-alphanumeric redis key prefix: '{key_prefix}'. Using default '{self.key_prefix}' instead."
f"Omitting provided non-alphanumeric redis key prefix: '{key_prefix}'. "
f"Using default '{self.key_prefix}' instead."
)

def _get_key_prefix(self) -> Text:
Expand Down Expand Up @@ -1139,7 +1140,9 @@ def _additional_events(
number_of_events_since_last_session = self._event_query(
session,
tracker.sender_id,
fetch_events_from_all_sessions=self.retrieve_events_from_previous_conversation_sessions,
fetch_events_from_all_sessions=(
self.retrieve_events_from_previous_conversation_sessions
),
).count()

return itertools.islice(
Expand Down
2 changes: 1 addition & 1 deletion rasa/core/training/converters/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from rasa.core.training.converters.story_markdown_to_yaml_converter import ( # noqa: F401
from rasa.core.training.converters.story_markdown_to_yaml_converter import ( # noqa: F401, E501
StoryMarkdownToYamlConverter,
)
3 changes: 2 additions & 1 deletion rasa/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ def _log_and_get_default_number_of_workers() -> int:

logger.debug(
f"Unable to assign desired number of Sanic workers ({env_value}) as "
f"no `RedisLockStore` or custom `LockStore` endpoint configuration has been found."
f"no `RedisLockStore` or custom `LockStore` endpoint "
f"configuration has been found."
)
return _log_and_get_default_number_of_workers()
4 changes: 2 additions & 2 deletions rasa/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,8 @@ async def model_fingerprint(file_importer: "TrainingDataImporter") -> Fingerprin
FINGERPRINT_CONFIG_NLU_KEY: _get_fingerprint_of_config(
config, include_keys=CONFIG_KEYS_NLU
),
FINGERPRINT_CONFIG_WITHOUT_EPOCHS_KEY: _get_fingerprint_of_config_without_epochs(
config
FINGERPRINT_CONFIG_WITHOUT_EPOCHS_KEY: (
_get_fingerprint_of_config_without_epochs(config)
),
FINGERPRINT_DOMAIN_WITHOUT_NLG_KEY: domain.fingerprint(),
FINGERPRINT_NLG_KEY: rasa.shared.utils.io.deep_container_fingerprint(responses),
Expand Down
6 changes: 4 additions & 2 deletions rasa/nlu/classifiers/keyword_intent_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,13 @@ def _validate_keyword_map(self) -> None:
for intent, keyword in ambiguous_mappings:
self.intent_keyword_map.pop(keyword)
logger.debug(
f"Removed keyword '{keyword}' from intent '{intent}' because it matched a "
"keyword of another intent."
f"Removed keyword '{keyword}' from intent "
f"'{intent}' because it matched a "
f"keyword of another intent."
)

def process(self, message: Message, **kwargs: Any) -> None:
"""Set the message intent and add it to the output is it exists."""
intent_name = self._map_keyword_to_intent(message.get(TEXT))

confidence = 0.0 if intent_name is None else 1.0
Expand Down
6 changes: 4 additions & 2 deletions rasa/nlu/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ def validate_component_keys(
for key in provided_keys:
if key not in allowed_keys:
rasa.shared.utils.io.raise_warning(
f"You have provided an invalid key `{key}` for component `{component_name}` in your pipeline. "
f"You have provided an invalid key `{key}` "
f"for component `{component_name}` in your pipeline. "
f"Valid options for `{component_name}` are:\n- "
f"{list_separator.join(allowed_keys)}"
)
Expand Down Expand Up @@ -356,7 +357,8 @@ def warn_of_competing_extractors(pipeline: List["Component"]) -> None:
rasa.shared.utils.io.raise_warning(
f"You have defined multiple entity extractors that do the same job "
f"in your pipeline: "
f"{', '.join(extractors_in_pipeline)}. This can lead to the same entity getting "
f"{', '.join(extractors_in_pipeline)}. "
f"This can lead to the same entity getting "
f"extracted multiple times. Please read the documentation section "
f"on entity extractors to make sure you understand the implications: "
f"{DOCS_URL_COMPONENTS}#entity-extractors"
Expand Down
Loading