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

Add pre commit with ruff #145

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

Conversation

getzze
Copy link
Contributor

@getzze getzze commented Feb 13, 2025

Replace isort, black, pylint, flake8 by ruff.
Add typos to correct for misspelled words.

Then use pre-commit to start the linter. pre-commit can be installed locally, so the linter is run before every commit to ensure the code is always clean.

I also added two changes that were mentioned in other issues:

  • remove the setuptools_scm dependency in the docs and use importlib.metadata
  • remove the _normalize_filename static method to used os.fspath instead. Also remove the tests associated to it.
  • the rest of the changes in src/pymediainfo/__init__.py are ruff recommendations.

(ruff still shows errors in scripts/download_library.py that I didn't correct because it would conflict with the changes of PR #144)

@@ -163,15 +163,12 @@ def __eq__(self, other: object) -> bool:
return self.tracks == other.tracks

def __init__(self, xml: str, encoding_errors: str = "strict") -> None:
xml_dom = ET.fromstring(xml.encode("utf-8", encoding_errors))
xml_dom = ET.fromstring(xml.encode("utf-8", encoding_errors)) # noqa: S314
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ruff recommendation is to use the defusedxml module instead of the stdlib because it corrects several vulnerabilities.
But it would add a dependency to the project.

@getzze
Copy link
Contributor Author

getzze commented Feb 14, 2025

the CI is failing on the scripts that I didn't clean on purpose.
All the rest is good

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