-
Notifications
You must be signed in to change notification settings - Fork 13
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: Base Class Implemenations #17
base: dev
Are you sure you want to change the base?
Feat: Base Class Implemenations #17
Conversation
src/classes/Build.py
Outdated
@@ -0,0 +1,33 @@ | |||
#!/usr/bin/env 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.
This does not work well for projects with external dependencies. The system Python interpreter is for system-level scripts. For your own applications, always use a virtual environment.
src/classes/Build.py
Outdated
class Build: | ||
def __init__(self, name: str = "temp") -> None: | ||
self.name = name | ||
self.tree_ref = Tree.Tree() |
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 Python, every variable is a reference to a value that lives somewhere else. Best to leave out the "ref" part, except when you would actually use weak references.
src/classes/Build.py
Outdated
self.tree_ref = Tree.Tree() | ||
self.player_ref = Player.Player() | ||
|
||
def __repr__(self) -> str: |
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.
__repr__
functions are intended for debugging only, not for human readable display. That's what __str__
is for. See https://docs.python.org/3/library/functions.html#repr and https://docs.python.org/3/library/functions.html#str
src/classes/Build.py
Outdated
@@ -0,0 +1,33 @@ | |||
#!/usr/bin/env python3 | |||
|
|||
# Build 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.
Consider replacing this redundant comment with a module-level docstring that describes teh purpose of this module.
src/classes/Build.py
Outdated
|
||
# Build Class | ||
# | ||
# Contains: |
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.
For a table of contents, you could either use your IDE's conde structure view or extract the structure with an automatic documentation builder tool like Sphinx.
src/classes/Player.py
Outdated
from enum import Enum | ||
|
||
|
||
class PlayerClasses(Enum): |
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.
Consider enum.IntEnum
and enum.auto
.
src/classes/Player.py
Outdated
self.player_class = player_class | ||
self.ascendancy = ascendancy | ||
self.level = level | ||
self.stats = 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.
Consider dict
literals.
src/classes/Tree.py
Outdated
# [dict] All Nodes (addressable by Node ID) | ||
# [dict] Allocated Nodes (addressable by Node ID) | ||
|
||
_VERSION_ = "3.17" |
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.
If this should be a constant that is private to the module, remove the trailing underscore. Trailing underscores are usually uses to avoid name conflicts with built-ins and keywords.
src/classes/Build.py
Outdated
return ret_str | ||
|
||
|
||
def test() -> None: |
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.
Usually, tests are contained in their own file hierarcy, starting from tests/
at the repository root.
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.
Packages and modules should have lowercase names. See https://www.python.org/dev/peps/pep-0008/#package-and-module-names
@@ -0,0 +1,17 @@ | |||
# Enumeration Data for Path of Exile constants |
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 should be a module-level docstring.
[optional set] Minions | ||
""" | ||
|
||
from Enumerations import PlayerClasses, PlayerAscendancies |
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 enums are currently used in a single place. It's best to keep them as local as possible. When they are used by more than one module on the same package, put them in a separate module. When they are used by more than one package, consider reworking the packages or put them in their own package.
[set] Allocated Nodes (addressable by Node ID) | ||
""" | ||
|
||
_VERSION_ = "3.17" |
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.
Consider storing version numbers as tuples.
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 you supply an example ? I'm too new to Python to understand what that means.
Why are you using enumerations and not dictionaries
I setup the colorCodes as a dictionary
I'm not sure of the advantages of either. X |
PEP 345 lists some reasons for using enums. Further advantages:
|
Currently I'm filling a combobox with self.colour_combo_box.addItems(color_codes.keys()) Whilst the color_codes naturally would be good as enums, what hoops to to go through to fill the combobox ? Or is there a different way to choose colours ? x |
You can iterate over an enum's variants and get their names: self.colour_combo_box.addItems([colour.name for colour in ColourCodes]) |
base implemenation of some classes following code_structures.md