-
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Expected Indents #3
base: main
Are you sure you want to change the base?
Conversation
Initialize empty source files
random word api
Update game.py
made dis into string from list
Update game.py
Update game.py
Update game.py
update dev-requirements
added win & lose features
added SVD and winning and loosing functionality
Updated words.json, minor bug fix in game.py - Game._get_random_word()
final fixes before welcome image
Docstring update + welcome image
quick readme
README and LICENSE update
Update README.md
slight change in readme
/* | ||
I forgot exactly how we decided the API response should be... so I assume it's like this: | ||
{ | ||
"word": "w_r_", | ||
"lives": 5, | ||
"image": "https://example.com/image.png" | ||
} | ||
*/ |
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.
This comment is a bit worrying, both it existing in first place as well as it still being there in the PR
Some notes that are not specific to any files, but overall recommendations:
Also, it might look like I reviewed extremely fast, but I took notes before officially starting the review - much of it was copy/pasting from the notes |
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.
forgot to actually Submit the review, sorry
str: A random uid. | ||
""" | ||
characters = string.ascii_letters + string.digits | ||
chars = [secrets.choice(characters) for _ in range(length)] |
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.
Why secrets.choice
instead of random.choices
?
Personally I'd probably just use an uuid.UUID4
instead to be honest
def __init__(self, lives=6): | ||
self.word = self._get_random_word() | ||
# print(self.word) | ||
self.total_lives = lives # const |
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.
Unused variable? (total_lives
)
script_dir = os.path.dirname(os.path.abspath(__file__)) | ||
file_path = os.path.join(script_dir, 'nouns-clear.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.
Use pathlib
over os.path
.
Arguably personal preferences, specially since it should work in any OS using either, but I still recommend pathlib
over it
""" | ||
script_dir = os.path.dirname(os.path.abspath(__file__)) | ||
file_path = os.path.join(script_dir, 'nouns-clear.txt') | ||
with open(file_path) as nounfile: |
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.
Preferably specify the mode and encoding whenever you're opening a file
The encoding doesn't matters much when all of the text in the file is ASCII, but the default encoding is currently platform dependent, the default encoding for Windows may change in the future, and I personally believe that it's better to explicit state the mode even when using the default ('r')
|
||
|
||
class Game: | ||
"""game class""" |
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.
May as well not have a docstring over just the name of the class. The comments in init
could be a bit tidier, but are passable
image = image.resize((self.size, self.size)) | ||
self.A = np.array(image) | ||
|
||
def reduce(self, terms, type=np.uint8): |
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.
avoid using built-in names such as type
as a variable name, for example you could use dtype
here matching numpy's terminology
type (numpy type, optional): Type of the returned array. Defaults to np.uint8. | ||
|
||
Returns: | ||
_type_: _description_ |
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.
forgot to change this? (line 76)
Raises: | ||
AssertionError: Game must exist, game_id must be a key the games dictionary. |
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.
In multiple docstrings you have "Raises AssetionError", but you do not actually use assert
in any of these places?
Side note: overall you might want to avoid using assert
(not that you have any in this project rn) and normally raise exceptions instead, in part since assert
is skipped if you use optimization command line arguments when running python (-OO
), in part so that you and other people using your code can catch them based on their type with except:
|
||
app = Flask(__name__) | ||
|
||
games = dict() |
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.
Avoid using global
variables, use Flask's Application Context instead.
Global variables are bug prone overall, specially in multi-threaded contexts
Also, you do not need to use the global
keyword to modify global variables, only to overwrite them. Do not use global variables either way though.
- Run `src/server.py` using python | ||
- In your browser, go to [`http://127.0.0.1:5000`](http://127.0.0.1:5000) | ||
### OR Visit the website: | ||
[http://picturepuzzlers.pythonanywhere.com/](http://picturepuzzlers.pythonanywhere.com/ "http://picturepuzzlers.pythonanywhere.com/") |
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.
No need to use []()
as far as I know? Just put it normally
No description provided.