Skip to content

Commit

Permalink
🚨 Code linting
Browse files Browse the repository at this point in the history
  • Loading branch information
HugoPerrier committed Dec 9, 2024
1 parent cc11fd1 commit 8f4e373
Show file tree
Hide file tree
Showing 8 changed files with 244 additions and 90 deletions.
4 changes: 0 additions & 4 deletions docs/tutorials/08_MelusineRegex.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ from melusine.base import MelusineRegex


class AnnoyingEmailsRegex(MelusineRegex):

@property
def positive(self) -> Union[str, Dict[str, str]]:
return dict(
Expand Down Expand Up @@ -65,7 +64,6 @@ from melusine.base import MelusineRegex


class AnnoyingEmailsRegex(MelusineRegex):

@property
def positive(self) -> Union[str, Dict[str, str]]:
return dict(
Expand Down Expand Up @@ -192,7 +190,6 @@ from melusine.base import MelusineRegex


class AnnoyingEmailsRegex(MelusineRegex):

@property
def positive(self) -> Union[str, Dict[str, str]]:
return dict(
Expand Down Expand Up @@ -237,7 +234,6 @@ That is were neutral regex can be of use. Whenever a neutral regex is matched, i

```python
class IfritAlertRegex(MelusineRegex):

@property
def positive(self) -> Union[str, Dict[str, str]]:
return dict(
Expand Down
1 change: 1 addition & 0 deletions melusine/processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -1556,6 +1556,7 @@ class RefinedTagger(MelusineTransformer):
"""
Post-processing class to refine initial tags.
"""

def __init__(
self,
input_columns: str = "messages",
Expand Down
5 changes: 1 addition & 4 deletions tests/detectors/test_thanks_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,7 @@ def test_thanks_detector_missing_field(thanks_detector_df):
],
False,
"Merci\nMerci a vous",
[
{"base_text": "Merci", "base_tag": "THANKS"},
{"base_text": "Merci a vous", "base_tag": "THANKS"}
],
[{"base_text": "Merci", "base_tag": "THANKS"}, {"base_text": "Merci a vous", "base_tag": "THANKS"}],
),
],
)
Expand Down
6 changes: 3 additions & 3 deletions tests/detectors/test_vacation_reply_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_instanciation():
{"base_tag": "HELLO", "base_text": "Bonjour,"},
{
"base_tag": "BODY",
"base_text": "je vous confirme l'annulation du rdv du 01/01/2022 à 16h."
"base_text": "je vous confirme l'annulation du rdv du 01/01/2022 à 16h.",
},
{"base_tag": "GREETINGS", "base_text": "Bien cordialement, John Smith."},
],
Expand All @@ -58,7 +58,7 @@ def test_instanciation():
{"base_tag": "HELLO", "base_text": "Bonjour,"},
{
"base_tag": "BODY",
"base_text": "Actuellement en conge je prendrai connaissance de votre message ulterieurement."
"base_text": "Actuellement en conge je prendrai connaissance de votre message ulterieurement.",
},
{"base_tag": "GREETINGS", "base_text": "Cordialement, "},
],
Expand Down Expand Up @@ -101,7 +101,7 @@ def test_transform(df, good_result):
{"base_tag": "HELLO", "base_text": "Bonjour,"},
{
"base_tag": "BODY",
"base_text": "Actuellement en conge je prendrai connaissance de votre message ulterieurement."
"base_text": "Actuellement en conge je prendrai connaissance de votre message ulterieurement.",
},
{"base_tag": "GREETINGS", "base_text": "Cordialement, "},
],
Expand Down
122 changes: 93 additions & 29 deletions tests/functional/test_emails_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,23 @@
[
{"base_text": "Bonjour,", "base_tag": "HELLO", "base_tag_list": ["HELLO"]},
{"base_text": "Vous trouverez ci-joint l'attestation", "base_tag": "BODY", "base_tag_list": ["BODY"]},
{"base_text": "Merci de me confirmer la bonne réception de ce message.", "base_tag": "BODY", "base_tag_list": ["BODY"]},
{
"base_text": "Merci de me confirmer la bonne réception de ce message.",
"base_tag": "BODY",
"base_tag_list": ["BODY"],
},
{"base_text": "Vous en remerciant par avance.", "base_tag": "THANKS", "base_tag_list": ["THANKS"]},
{"base_text": "Cordialement,", "base_tag": "GREETINGS", "base_tag_list": ["GREETINGS"]},
{"base_text": "Jean Dupont", "base_tag": "BODY", "base_tag_list": ["BODY"]},
],
[
{"base_text": "Bonjour,", "base_tag": "HELLO", "base_tag_list": ["HELLO"]},
{"base_text": "Veuillez trouver ci-jointe la lettre", "base_tag": "BODY", "base_tag_list": ["BODY"]},
{"base_text": "La visualisation des fichiers PDF nécessite Adobe Reader.", "base_tag": "FOOTER", "base_tag_list": ["FOOTER"]},
{
"base_text": "La visualisation des fichiers PDF nécessite Adobe Reader.",
"base_tag": "FOOTER",
"base_tag_list": ["FOOTER"],
},
{"base_text": "Sentiments mutualistes.", "base_tag": "GREETINGS", "base_tag_list": ["GREETINGS"]},
{"base_text": "La MAIF", "base_tag": "BODY", "base_tag_list": ["BODY"]},
],
Expand All @@ -147,27 +155,63 @@
"messages.tags": [
[
{"base_text": "Bonjour,", "base_tag": "HELLO", "base_tag_list": ["HELLO"], "refined_tag": "HELLO"},
{"base_text": "Vous trouverez ci-joint l'attestation", "base_tag": "BODY", "base_tag_list": ["BODY"],
"refined_tag": "BODY"},
{"base_text": "Merci de me confirmer la bonne réception de ce message.", "base_tag": "BODY",
"base_tag_list": ["BODY"], "refined_tag": "BODY"},
{"base_text": "Vous en remerciant par avance.", "base_tag": "THANKS", "base_tag_list": ["THANKS"],
"refined_tag": "THANKS"},
{"base_text": "Cordialement,", "base_tag": "GREETINGS", "base_tag_list": ["GREETINGS"],
"refined_tag": "GREETINGS"},
{"base_text": "Jean Dupont", "base_tag": "BODY", "base_tag_list": ["BODY"],
"refined_tag": "SIGNATURE_NAME"},
{
"base_text": "Vous trouverez ci-joint l'attestation",
"base_tag": "BODY",
"base_tag_list": ["BODY"],
"refined_tag": "BODY",
},
{
"base_text": "Merci de me confirmer la bonne réception de ce message.",
"base_tag": "BODY",
"base_tag_list": ["BODY"],
"refined_tag": "BODY",
},
{
"base_text": "Vous en remerciant par avance.",
"base_tag": "THANKS",
"base_tag_list": ["THANKS"],
"refined_tag": "THANKS",
},
{
"base_text": "Cordialement,",
"base_tag": "GREETINGS",
"base_tag_list": ["GREETINGS"],
"refined_tag": "GREETINGS",
},
{
"base_text": "Jean Dupont",
"base_tag": "BODY",
"base_tag_list": ["BODY"],
"refined_tag": "SIGNATURE_NAME",
},
],
[
{"base_text": "Bonjour,", "base_tag": "HELLO", "base_tag_list": ["HELLO"], "refined_tag": "HELLO"},
{"base_text": "Veuillez trouver ci-jointe la lettre", "base_tag": "BODY", "base_tag_list": ["BODY"],
"refined_tag": "BODY"},
{"base_text": "La visualisation des fichiers PDF nécessite Adobe Reader.", "base_tag": "FOOTER",
"base_tag_list": ["FOOTER"], "refined_tag": "FOOTER"},
{"base_text": "Sentiments mutualistes.", "base_tag": "GREETINGS", "base_tag_list": ["GREETINGS"],
"refined_tag": "GREETINGS"},
{"base_text": "La MAIF", "base_tag": "BODY", "base_tag_list": ["BODY"],
"refined_tag": "SIGNATURE_NAME"},
{
"base_text": "Veuillez trouver ci-jointe la lettre",
"base_tag": "BODY",
"base_tag_list": ["BODY"],
"refined_tag": "BODY",
},
{
"base_text": "La visualisation des fichiers PDF nécessite Adobe Reader.",
"base_tag": "FOOTER",
"base_tag_list": ["FOOTER"],
"refined_tag": "FOOTER",
},
{
"base_text": "Sentiments mutualistes.",
"base_tag": "GREETINGS",
"base_tag_list": ["GREETINGS"],
"refined_tag": "GREETINGS",
},
{
"base_text": "La MAIF",
"base_tag": "BODY",
"base_tag_list": ["BODY"],
"refined_tag": "SIGNATURE_NAME",
},
],
],
},
Expand Down Expand Up @@ -202,7 +246,11 @@
"messages.tags": [
[
{"base_text": "Bonjour", "base_tag": "HELLO", "base_tag_list": ["HELLO"]},
{"base_text": "Pouvez-vous me transmettre deux attestations au nom de mes enfants", "base_tag": "BODY", "base_tag_list": ["BODY"]},
{
"base_text": "Pouvez-vous me transmettre deux attestations au nom de mes enfants",
"base_tag": "BODY",
"base_tag_list": ["BODY"],
},
{"base_text": "- Jane Dupond", "base_tag": "BODY", "base_tag_list": ["BODY"]},
{"base_text": "- Joe Dupond", "base_tag": "BODY", "base_tag_list": ["BODY"]},
{"base_text": "Merci par avance", "base_tag": "THANKS", "base_tag_list": ["THANKS"]},
Expand All @@ -215,16 +263,32 @@
"messages.tags": [
[
{"base_text": "Bonjour", "base_tag": "HELLO", "base_tag_list": ["HELLO"], "refined_tag": "HELLO"},
{"base_text": "Pouvez-vous me transmettre deux attestations au nom de mes enfants", "base_tag": "BODY",
"base_tag_list": ["BODY"], "refined_tag": "BODY"},
{
"base_text": "Pouvez-vous me transmettre deux attestations au nom de mes enfants",
"base_tag": "BODY",
"base_tag_list": ["BODY"],
"refined_tag": "BODY",
},
{"base_text": "- Jane Dupond", "base_tag": "BODY", "base_tag_list": ["BODY"], "refined_tag": "BODY"},
{"base_text": "- Joe Dupond", "base_tag": "BODY", "base_tag_list": ["BODY"], "refined_tag": "BODY"},
{"base_text": "Merci par avance", "base_tag": "THANKS", "base_tag_list": ["THANKS"],
"refined_tag": "THANKS"},
{"base_text": "Cordialement", "base_tag": "GREETINGS", "base_tag_list": ["GREETINGS"],
"refined_tag": "GREETINGS"},
{"base_text": "Mr Jean Dupond", "base_tag": "BODY", "base_tag_list": ["BODY"],
"refined_tag": "SIGNATURE_NAME"},
{
"base_text": "Merci par avance",
"base_tag": "THANKS",
"base_tag_list": ["THANKS"],
"refined_tag": "THANKS",
},
{
"base_text": "Cordialement",
"base_tag": "GREETINGS",
"base_tag_list": ["GREETINGS"],
"refined_tag": "GREETINGS",
},
{
"base_text": "Mr Jean Dupond",
"base_tag": "BODY",
"base_tag_list": ["BODY"],
"refined_tag": "SIGNATURE_NAME",
},
]
],
},
Expand Down
3 changes: 1 addition & 2 deletions tests/gmail/test_gmail.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
import pytest

import pandas as pd
from unittest.mock import MagicMock, patch


HttpRequestMock = pytest.importorskip('googleapiclient.http.HttpRequestMock')
from google.oauth2.credentials import Credentials
from unittest.mock import MagicMock, patch
from melusine.connectors.gmail import GmailConnector


Expand Down
Loading

0 comments on commit 8f4e373

Please sign in to comment.