osl-incubator / scicookie

Cookiecutter template for a Python package.
https://osl-incubator.github.io/scicookie
Other
10 stars 18 forks source link

feat(ruff): add option for ruff as linter and auto-formatter #298

Closed Naman-Priyadarshi closed 1 week ago

Naman-Priyadarshi commented 3 weeks ago

Pull Request description

This pull request introduces two separate configuration options for ruff: linter and auto-formatter. These changes enhance the flexibility of our code quality tools, allowing users to choose whether they want to use Ruff solely as a linter, solely as an auto-formatter, or both.

Also added both the configurations to the osl profile and base profile.

WIP: Adding documentation to guide.md

Fixes #220

How to test these changes

makim tests.unittest or create a project manually

Pull Request checklists

This PR is a:

About this PR:

Author's checklist:

Additional information

Reviewer's checklist

Copy and paste this template for your review's note:

## Reviewer's Checklist

- [ ] I managed to reproduce the problem locally from the `main` branch
- [ ] I managed to test the new changes locally
- [ ] I confirm that the issues mentioned were fixed/resolved
xmnlab commented 2 weeks ago

Hey @Naman-Priyadarshi , it seems that there is 1 file that needs an format update, according to ruff formatter ... let me know if you need any help to identify what need to be done

Naman-Priyadarshi commented 2 weeks ago

I tried running pre-commit run --all-files --verbose and received the output that All checks passed!. Is there any other command I should use or find it manually in the changed files?

xmnlab commented 2 weeks ago
diff --git a/src/osl_python_package/__init__.py b/src/osl_python_package/__init__.py
index 87fa060..d5d5599 100644
--- a/src/osl_python_package/__init__.py
+++ b/src/osl_python_package/__init__.py
@@ -8,11 +8,11 @@ def get_version() -> str:
     try:
         return importlib_metadata.version(__name__)
     except importlib_metadata.PackageNotFoundError:  # pragma: no cover
-        return '0.1.0'  # semantic-release
+        return "0.1.0"  # semantic-release

 version = get_version()

 __version__ = version
Naman-Priyadarshi commented 1 week ago

Hi @xmnlab, the test seems to be failing due to some miscellaneous error

  at ~/miniconda3/envs/osl-python-package/lib/python3.12/site-packages/poetry/utils/env/base_env.py:342 in _run
      338│                 output = subprocess.check_output(
      339│                     cmd, stderr=stderr, env=env, text=True, **kwargs
      340│                 )
      341│         except CalledProcessError as e:
    → 342│             raise EnvCommandError(e)
      343│ 
      344│         return output
      345│ 
      346│     def execute(self, bin: str, *args: str, **kwargs: Any) -> int:

Cannot install rapidfuzz.

Could you help me out here? Thank you!

xmnlab commented 1 week ago

Hi @xmnlab, the test seems to be failing due to some miscellaneous error

  at ~/miniconda3/envs/osl-python-package/lib/python3.12/site-packages/poetry/utils/env/base_env.py:342 in _run
      338│                 output = subprocess.check_output(
      339│                     cmd, stderr=stderr, env=env, text=True, **kwargs
      340│                 )
      341│         except CalledProcessError as e:
    → 342│             raise EnvCommandError(e)
      343│ 
      344│         return output
      345│ 
      346│     def execute(self, bin: str, *args: str, **kwargs: Any) -> int:

Cannot install rapidfuzz.

Could you help me out here? Thank you!

hi @Naman-Priyadarshi ! when things weird like that happen in CI, just restart that to check if it is some random issue in the installation ... usually that fix the problem.

if it is something about distlib ... maybe it is some conflict between conda and poetry .. so usually I just add that dep inside the conda environment file in the pip section ... usually that fix the issue

in this case I just restarted the CI and everything is working

xmnlab commented 1 week ago

thanks for working on that @Naman-Priyadarshi

Naman-Priyadarshi commented 1 week ago

Hi @xmnlab, the test seems to be failing due to some miscellaneous error


  at ~/miniconda3/envs/osl-python-package/lib/python3.12/site-packages/poetry/utils/env/base_env.py:342 in _run

      338│                 output = subprocess.check_output(

      339│                     cmd, stderr=stderr, env=env, text=True, **kwargs

      340│                 )

      341│         except CalledProcessError as e:

    → 342│             raise EnvCommandError(e)

      343│ 

      344│         return output

      345│ 

      346│     def execute(self, bin: str, *args: str, **kwargs: Any) -> int:

Cannot install rapidfuzz.

Could you help me out here? Thank you!

hi @Naman-Priyadarshi ! when things weird like that happen in CI, just restart that to check if it is some random issue in the installation ... usually that fix the problem.

if it is something about distlib ... maybe it is some conflict between conda and poetry .. so usually I just add that dep inside the conda environment file in the pip section ... usually that fix the issue

in this case I just restarted the CI and everything is working

yeah that makes complete sense, the problem is that maybe I don't have permissions to restart the ci! that's why I mentioned you to do it for me hahaha, anyways thank you 😁