-
Notifications
You must be signed in to change notification settings - Fork 837
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
feat(code quality): add black and ruff #56
base: main
Are you sure you want to change the base?
Conversation
Thanks for contributing! Could you split the PR between the streamlined installation changes and black and ruff changes? Want to consider those changes separately. Also I think we should ignore linting custom_speech_recognition since its just a copy of the existing SpeechRecognition library with some modifications. Probably a better way to maintain that I haven't considered how. |
I see, I didn't realize it was a copy of an existing SpeechRecognition library. In that case, I will ignore it in regards to linting and formatting. Would it make sense to do something like this - where the library is its own git repo? Example from: https://github.com/foundry-rs/foundry-rust-template/tree/master/contracts/lib |
Makefile
Outdated
lint: | ||
@echo | ||
ruff . | ||
@echo | ||
black --check --diff --color . | ||
@echo | ||
pip-audit | ||
|
||
format: | ||
ruff --silent --exit-zero --fix . | ||
black . | ||
|
||
precommit: | ||
make lint | ||
make format | ||
|
||
venv: | ||
python3 -m venv ecout_env | ||
|
||
install: | ||
pip install -r requirements.txt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are the streamlined installation changes, let me know if it is necessary to split the PR.
README.md
Outdated
|
||
### Installation | ||
|
||
1. `make venv` | ||
2. Activate the venv: `ecout_venv` | ||
3. `make install` | ||
|
||
### Code quality | ||
|
||
Before submitting a pull request run `make precommit` and resolve any issues. Additionally, here are some useful commands: | ||
|
||
- `make lint` | ||
- `make format` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are the streamlined installation changes, let me know if it is necessary to split the PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh Sry! Got confused with the Installation section above.
Makefile
Outdated
make format | ||
|
||
venv: | ||
python3 -m venv ecout_env |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
python or python3?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think python3 is preferred since we are working with Python 3.x.x
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could somehow use either? For me I don't have python3 alias only python in my PATH.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I can change it to python instead of python3.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
black . | ||
|
||
precommit: | ||
make lint |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably have instructions to install 'make' as well, chocolatey seems easiest
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it's built-in on MacOS and Linux, not sure about Windows.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Windows you have to install it
installing choco with the commad in README and using
choco install make
would be good enough for instructions
README.md
Outdated
### Installation | ||
|
||
1. `make venv` | ||
2. Activate the venv: `ecout_venv` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ecout_env\Scripts\activate ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, I'll add one script for MacOS and one for Windows.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, sorry. I tried adding a script, but it's not possible to activate the venv with a make command. I'll add both options to the README: for MacOS it's source ecout_env/bin/activate
Hmm, I'm not sure. Maybe the way black behaves is different on windows. Can you try modifying a python file to contain single quotes for a string, instead of double quotes, and see if you get the same message. Perhaps it's behaving normally? |
#### Windows | ||
|
||
1. Install make on your Windows machine. | ||
|
||
```shell | ||
choco install make | ||
``` | ||
|
||
2. Create a virtual environment: | ||
|
||
```shell | ||
make venv | ||
``` | ||
|
||
3. Activate the virtual environment: | ||
|
||
```shell | ||
.\ecout_venv\Scripts\activate | ||
``` | ||
|
||
4. Install the required packages: | ||
|
||
```shell | ||
make install | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please confirm these steps work.
I think this is good to go. If you get a chance to review + merge, I would appreciate it. Thanks! |
I added black and ruff to maintain code quality and implemented a Makefile streamline the execution of common commands.
I also tried to add poetry as the dependency manager, but it was not compatible with the dependency
openai-whisper
. It seemed to consistently fail on the installation oftritton
.For reference, this is as far as I was able to get:
It fails with this error (there was another one for tritton, but I seemed to have lost it somewhere in my console):
I noticed another developer had a similar issue: https://github.com/orgs/python-poetry/discussions/7199