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

CI: modernize #1946

Merged
merged 2 commits into from
Jan 20, 2024
Merged

CI: modernize #1946

merged 2 commits into from
Jan 20, 2024

Conversation

BoboTiG
Copy link
Owner

@BoboTiG BoboTiG commented Jan 20, 2024

Use ruff + pyproject.toml for configurations. ./checks.sh is blazing fast now (it was always slow when dealing with the big svg_cache.py file).

Most of the changes are done by ruff format, it's a one-time clean-up.

Relevant issues found, and fixed, are:

  • scripts/pt-langs.py was not handling duplicate entries;
  • wikidict/lang/fr/ko_hangeul.py had a duplicate entry.

target-version = "py311"

[tool.ruff.lint]
extend-select = ["I"]
Copy link
Owner Author

Choose a reason for hiding this comment

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

We might add more rules later, I just did the minimum right now. It's open to PR :)

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

PR Type: Refactoring

PR Summary: The pull request focuses on modernizing the CI process by switching to 'ruff' for code formatting and linting, which is configured via 'pyproject.toml'. The changes are mostly automated code clean-up performed by 'ruff format'. The PR also addresses issues with duplicate entries in 'scripts/pt-langs.pt' and 'wikidict/lang/fr/ko_hangeul.py'.

Decision: Comment

📝 Type: 'Refactoring' - not supported yet.
  • Sourcery currently only approves 'Typo fix' PRs.
✅ Issue addressed: this change correctly addresses the issue or implements the desired feature.
No details provided.
📝 Complexity: the changes are too large or complex for Sourcery to approve.
  • Unsupported files: the diff contains files that Sourcery does not currently support during reviews.
  • Files deleted: Sourcery does not currently approve diffs with deleted files.
  • Big diff: the diff is too large to approve with confidence.

General suggestions:

  • Ensure that the removal of mappings and changes in the code do not introduce any regressions or alter the intended behavior.
  • Verify that the refactoring and code simplifications maintain the readability and maintainability of the codebase.
  • Confirm that the changes made are consistent with the project's coding standards and practices.

Thanks for using Sourcery. We offer it for free for open source projects and would be very grateful if you could help us grow. If you like it, would you consider sharing Sourcery on your favourite social media? ✨

Share Sourcery

Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

diacritiques = any(
char in texte for char in ["a", "i", "u", "â", "î", "û", "ã", "ĩ", "ũ", "°"]
)
diacritiques = any(char in texte for char in ["a", "i", "u", "â", "î", "û", "ã", "ĩ", "ũ", "°"])
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion (llm): Consider using a set for the diacritiques list since the 'in' operation is more efficient with sets than lists, especially if this operation is performed multiple times.

and texte[curseur - 3 : curseur]
in (" el", " ^l", " bi", " fa", " ka", " la", " li", " wa")
and a_traiter != "'" # -- Pb de la hamza dans des mots comme bi'r, ne pas traiter comme un préfixe
and texte[curseur - 3 : curseur] in (" el", " ^l", " bi", " fa", " ka", " la", " li", " wa")
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion (llm): The tuple of strings used for checking the substring in 'texte' is repeated multiple times. Consider storing it in a variable to avoid repetition and improve maintainability.

and texte[curseur - 2 : curseur] != "ât"
and texte[curseur + 1] != "é"
):
if texte[curseur - 1] != "@" and texte[curseur - 2 : curseur] != "ât" and texte[curseur + 1] != "é":
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion (llm): This conditional check is complex and repeated in the code. Consider refactoring it into a separate function for clarity and reuse.

@@ -182,7 +182,6 @@
"ㅈㄴ": "ㄴㄴ",
"ㅊㄴ": "ㄴㄴ",
"ㅌㄴ": "ㄴㄴ",
"ㅎㄴ": "ㄴㄴ",
Copy link
Contributor

Choose a reason for hiding this comment

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

question (llm): Ensure that the removal of the 'ㅎㄴ': 'ㄴㄴ' mapping is intentional and does not affect the correctness of the Hangul processing.

lua_code = re.sub(
r"aliases\s*=\s*{([^}]*)}", "", lua_code, 0, re.MULTILINE | re.DOTALL
)
lua_code = re.sub(r"aliases\s*=\s*{([^}]*)}", "", lua_code, 0, re.MULTILINE | re.DOTALL)
Copy link
Contributor

Choose a reason for hiding this comment

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

question (llm): The simplification of the regex substitution is good, but ensure that it correctly handles all cases, especially when dealing with nested or complex Lua table structures.

phrase = ("D" if data["m"] else "d") + (
"érivée" if data["f"] in ("1", "oui", "o", "i") else "érivé"
)
phrase = ("D" if data["m"] else "d") + ("érivée" if data["f"] in ("1", "oui", "o", "i") else "érivé")
Copy link
Contributor

Choose a reason for hiding this comment

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

praise (llm): The refactoring of the conditional phrase construction improves readability by removing unnecessary parentheses.

@BoboTiG BoboTiG merged commit c67373c into master Jan 20, 2024
1 check passed
@BoboTiG BoboTiG deleted the feat-modernize-ci branch January 20, 2024 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant