Feat: Base Class Implemenations#17
Feat: Base Class Implemenations#17Nostrademous wants to merge 3 commits intoPathOfBuildingCommunity:devfrom
Conversation
src/classes/Build.py
Outdated
| @@ -0,0 +1,33 @@ | |||
| #!/usr/bin/env python3 | |||
There was a problem hiding this comment.
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.
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.
__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.
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.
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.
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() |
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.
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.
Usually, tests are contained in their own file hierarcy, starting from tests/ at the repository root.
ppoelzl
left a comment
There was a problem hiding this comment.
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.
This should be a module-level docstring.
| [optional set] Minions | ||
| """ | ||
|
|
||
| from Enumerations import PlayerClasses, PlayerAscendancies |
There was a problem hiding this comment.
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.
Consider storing version numbers as tuples.
There was a problem hiding this comment.
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