farisfaikar / Number-Game

Number Game is a game where players solve a 4-digit secret number combination using clever deductions!
MIT License
17 stars 9 forks source link

impl automated formatting and import sorting #46

Closed coldenate closed 2 years ago

coldenate commented 2 years ago

Implementation of isort and Black Formatting

Hi there! πŸ‘‹ This pr is designed to address issue #42. I manually formatted and sorted each file. I implemented a test to verify.

In short, I added a check if all files are sorted and formatted, and I added a vscode config to suggest any developer with the workspace open to set up isort and black formatting.

Checklist

Goal

The goal of this branch is to implement two modes of isort and Black formatting.

  1. "Checks"
  2. Traditional

The "checks" mode is administered via the Github action. This action will run Isort and Black formatting on every python file inside the src directory. This will return an error if there are any formatting errors or sorting errors. The badge looks like this:

image

This could be useful for pull requests from developers who do not have isort and black set up.

The "traditional" mode is the implementation of the VSCode extension suggestions. When the workspace is opened in vs code, the editor will check if the iSort and black formatting extensions are installed. If they are not installed, it will provide a prompt for the developer.

This is what it looks like when everything passes and there are no formatting or sorting errors! image
farisfaikar commented 2 years ago

Looks awesome! I'm testing it out right now

coldenate commented 2 years ago

Whoops 🀦, I forgot to mention @R0merol, I updated the ./code directory to ./src. If you would like me to revert it, please let me know. It may help with #9.

farisfaikar commented 2 years ago

Strange, it seems like the linting cannot recognize pygame on my end image

coldenate commented 2 years ago

Make sure that the python environment you use has the correct requirements installed. However, pylint was not initially requested in the issue, and is not necessary. Pylint is kinda like a perfectionist format. It opens up the pep rulebook and starts searching for issues. The bottom line is that pylint usually will complain about stuff that won't inhibit the code running, and that if it bugs you, you can turn it off. I highly recommend developing with pylint, so I included it in the suggestions. Pylint is not Black formatting nor import sorting.

I hope that helps! :)

farisfaikar commented 2 years ago

Whoops 🀦, I forgot to mention @R0merol, I updated the ./code directory to ./src. If you would like me to revert it, please let me know. It may help with https://github.com/R0merol/Number-Game-v0.1/issues/9.

Oh yea, about that. Does using src instead of code the standard way of doing it? If so, then I'll switch to src. Also, regarding the lining, I might have to move this to a test branch to see how it works first

coldenate commented 2 years ago

From my experience, using src is pretty standard. Although it's really up to you, I used it in my code because it stands for source. The pylint won't actually affect the game running, but I agree with testing it! Pylint works wonders for pythonistas! @R0merol Let me know if you have any requested revisions! I am glad this is working out! πŸ˜„

farisfaikar commented 2 years ago

Can you resolve the conflicts first? Thank you

coldenate commented 2 years ago

Sure! I'll revert to 'code' instead of 'src'. That seemed to be the only conflict.

farisfaikar commented 2 years ago

Actually, you can keep it as src. I'm planning on converting it to that name anyways

coldenate commented 2 years ago

Ok. I think that is the conflict. Your branch is 'code' but my branch is 'src'.

farisfaikar commented 2 years ago

Looks like there's still conflict, perhaps with the README.md file as I changed the game's description. I'll try and merge it as soon as it's resolved

coldenate commented 2 years ago

I think i fixed the readme thing. It’s just the directory thing. Are you going to change the directory name on your branch?

farisfaikar commented 2 years ago

Yes, go ahead and change it

coldenate commented 2 years ago

I don’t have access to your branch. For the merge conflict to go away, I either have to change my branch to code or you have to change your branch to src. ( I think ) πŸ˜… It’s a little confusing.

farisfaikar commented 2 years ago

Okay, just change it to code for now. Just make sure the conflict is resolved so I can merge it

coldenate commented 2 years ago

Awesome work my friend! I love your game! πŸ˜„