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

Feature/pre commit #24

Merged
merged 6 commits into from
Aug 1, 2024
Merged

Feature/pre commit #24

merged 6 commits into from
Aug 1, 2024

Conversation

zacdezgeo
Copy link
Collaborator

@zacdezgeo zacdezgeo commented Jul 31, 2024

What I Changed

  • Add pre-commit support with ruff, mypy, and pytest
  • Required changing relative path handling for the env file in the space2stats_api/app/settings.py

How to test it

  • Run tests and spin up API:
cd space2stats_api
python -m pytest
uvicorn app.main:app --reload 
  • Run pre-commit
pre-commit run --all-files

Other Notes

  • Seeking feedback on how to manage relative file path to env file. Currently wrote a short snippet here, but it feels jenky:
current_directory = os.getcwd()    
env_file_name = 'local_db.env'

if os.path.basename(current_directory) == "space2stats_api":
    env_path = os.path.join(current_directory, '..', env_file_name)
else:
    env_path = os.path.join(current_directory, env_file_name)

Fix errors and warning flagged by mypy around typing.
Required adding relative path handling to settings.py to manage running uvicorn/pytest from the space2stats_api directory but also support running pre-commit from the root.
@zacdezgeo zacdezgeo added the enhancement New feature or request label Jul 31, 2024
@zacdezgeo zacdezgeo self-assigned this Jul 31, 2024
@vincentsarago
Copy link
Collaborator

we can also add a step in the CI to run the pre-commit https://github.com/cogeotiff/rio-tiler/blob/8573dbe7b3ea7325e7db084f29bc47f9797d0bbe/.github/workflows/ci.yml#L38-L42

Remove execution of tests on pre-commit. Remove current directory check for setting path of env file.
@zacdezgeo zacdezgeo requested a review from vincentsarago August 1, 2024 14:52
@zacdezgeo zacdezgeo requested a review from vincentsarago August 1, 2024 15:45
@zacdezgeo zacdezgeo merged commit 0a96ba1 into main Aug 1, 2024
2 checks passed
@zacdezgeo zacdezgeo deleted the feature/pre-commit branch August 1, 2024 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add ruff and mypy with pre-commit configuration
2 participants