From 170459658968449ea44663695e45e95c56f3e575 Mon Sep 17 00:00:00 2001 From: Victor Payno Date: Wed, 17 Jan 2024 08:51:55 -0800 Subject: [PATCH] python/ellens-alien-game: 3rd iteration - pylint fixes --- python/ellens-alien-game/.coverage | Bin 53247 -> 53247 bytes python/ellens-alien-game/.coverage.xml | 19 ++-- python/ellens-alien-game/classes.py | 6 +- python/ellens-alien-game/classes.py,cover | 6 +- python/ellens-alien-game/run-tests-python.txt | 96 +++++++++--------- 5 files changed, 65 insertions(+), 62 deletions(-) diff --git a/python/ellens-alien-game/.coverage b/python/ellens-alien-game/.coverage index 431b958a359ba4bd1f64692b445d389c5b89212a..30d930cf63c9f46735650f7012aa0abb74b4f4bb 100644 GIT binary patch delta 447 zcmXxfJ5Iwu6op|~0gl`x&inmvhRCvPO<|2>nXv>NB^4WB1vJzYEFlZX4oIXdAPrPV zF5I|q;Z>wbW1O3t?$c?G{&G_*H?`f*_opr)ZcWoLVvQw1$FK>J#)1$=m=jcj*#!zy zLZUDs1R=%*nPNmpC5D&fgaN_N&?k64dW7uBLzm=AbO=t4HX(P=BCK3A38H{SC9_H%XT=RW^_nq)DA3OYj1`gV>T6;3lb3 zQBWWuv5GWq2tGOKK20qwksq31SC#>z%fC!mUOv9+sXlhS5s$e$WI6tTWfy%`VfR>;(`AXW!zzWrs!Lzbk6L*8I&Y0% D@~J(B diff --git a/python/ellens-alien-game/.coverage.xml b/python/ellens-alien-game/.coverage.xml index 8afcc026..b48d3e26 100644 --- a/python/ellens-alien-game/.coverage.xml +++ b/python/ellens-alien-game/.coverage.xml @@ -1,5 +1,5 @@ - + @@ -20,20 +20,19 @@ - - + - - - - - - - + + + + + + + diff --git a/python/ellens-alien-game/classes.py b/python/ellens-alien-game/classes.py index 3775bfa0..46bb3322 100644 --- a/python/ellens-alien-game/classes.py +++ b/python/ellens-alien-game/classes.py @@ -31,20 +31,24 @@ def __init__(self, x_coordinate: int, y_coordinate: int) -> None: self.health: int = 3 def hit(self) -> None: + """Hits do health damage.""" self.health -= 1 def is_alive(self) -> bool: + """The alien is alive as long as it's health isn't zero.""" return self.health > 0 def teleport(self, x_coordinate: int, y_coordinate: int) -> None: + """Teleports the alien to a new set of coordinates.""" self.x_coordinate = x_coordinate self.y_coordinate = y_coordinate def collision_detection(self, other: object) -> None: - pass + """Aliens don't have car insurance so ignore collisions.""" def new_aliens_collection(positions: List[Tuple[int, int]]) -> List[Alien]: + """Returns a new list of aliens""" return [Alien(*position) for position in positions] diff --git a/python/ellens-alien-game/classes.py,cover b/python/ellens-alien-game/classes.py,cover index 197cdbbe..c1b57f58 100644 --- a/python/ellens-alien-game/classes.py,cover +++ b/python/ellens-alien-game/classes.py,cover @@ -31,20 +31,24 @@ > self.health: int = 3 > def hit(self) -> None: +> """Hits do health damage.""" > self.health -= 1 > def is_alive(self) -> bool: +> """The alien is alive as long as it's health isn't zero.""" > return self.health > 0 > def teleport(self, x_coordinate: int, y_coordinate: int) -> None: +> """Teleports the alien to a new set of coordinates.""" > self.x_coordinate = x_coordinate > self.y_coordinate = y_coordinate > def collision_detection(self, other: object) -> None: -> pass +> """Aliens don't have car insurance so ignore collisions.""" > def new_aliens_collection(positions: List[Tuple[int, int]]) -> List[Alien]: +> """Returns a new list of aliens""" > return [Alien(*position) for position in positions] diff --git a/python/ellens-alien-game/run-tests-python.txt b/python/ellens-alien-game/run-tests-python.txt index 827ac7a5..9cde79ee 100644 --- a/python/ellens-alien-game/run-tests-python.txt +++ b/python/ellens-alien-game/run-tests-python.txt @@ -4,28 +4,22 @@ Running automated test file(s): =============================================================================== Running: pylint ./src -************* Module ellens_alien_game.classes -src/ellens_alien_game/classes.py:33:4: C0116: Missing function or method docstring (missing-function-docstring) -src/ellens_alien_game/classes.py:36:4: C0116: Missing function or method docstring (missing-function-docstring) -src/ellens_alien_game/classes.py:39:4: C0116: Missing function or method docstring (missing-function-docstring) -src/ellens_alien_game/classes.py:43:4: C0116: Missing function or method docstring (missing-function-docstring) -src/ellens_alien_game/classes.py:47:0: C0116: Missing function or method docstring (missing-function-docstring) ------------------------------------------------------------------- -Your code has been rated at 7.83/10 (previous run: 8.33/10, -0.51) +------------------------------------------------------------------- +Your code has been rated at 10.00/10 (previous run: 9.57/10, +0.43) -real 0m0.831s -user 0m0.726s -sys 0m0.109s +real 0m0.752s +user 0m0.683s +sys 0m0.071s =============================================================================== Running: ruff check --ignore E501 ./src -real 0m0.087s -user 0m0.039s -sys 0m0.053s +real 0m0.071s +user 0m0.028s +sys 0m0.044s =============================================================================== @@ -33,7 +27,7 @@ Running: pyright --stats ./src Found 2 source files pyright 1.1.347 0 errors, 0 warnings, 0 informations -Completed in 0.585sec +Completed in 0.553sec Analysis stats Total files parsed and bound: 20 @@ -41,17 +35,17 @@ Total files checked: 2 Timing stats Find Source Files: 0sec -Read Source Files: 0sec +Read Source Files: 0.01sec Tokenize: 0.04sec Parse: 0.04sec -Resolve Imports: 0.06sec -Bind: 0.07sec +Resolve Imports: 0.04sec +Bind: 0.05sec Check: 0.06sec Detect Cycles: 0sec -real 0m1.487s -user 0m1.317s -sys 0m0.169s +real 0m1.332s +user 0m1.086s +sys 0m0.183s =============================================================================== @@ -61,17 +55,19 @@ Running: bandit --verbose --recursive ./src [main] INFO cli include tests: None [main] INFO cli exclude tests: None [main] INFO running on Python 3.12.1 -Run started:2024-01-17 05:28:25.660640 +Run started:2024-01-17 16:51:05.583963 Files in scope (2): ./src/ellens_alien_game/__init__.py (score: {SEVERITY: 0, CONFIDENCE: 0}) ./src/ellens_alien_game/classes.py (score: {SEVERITY: 0, CONFIDENCE: 0}) -Files excluded (0): +Files excluded (2): + ./src/ellens_alien_game/__pycache__/__init__.cpython-312.pyc + ./src/ellens_alien_game/__pycache__/classes.cpython-312.pyc Test results: No issues identified. Code scanned: - Total lines of code: 38 + Total lines of code: 42 Total lines skipped (#nosec): 0 Total potential issues skipped due to specifically being disabled (e.g., #nosec BXXX): 0 @@ -88,17 +84,17 @@ Run metrics: High: 0 Files skipped (0): -real 0m0.288s -user 0m0.214s -sys 0m0.076s +real 0m0.306s +user 0m0.225s +sys 0m0.083s =============================================================================== Running: refurb ./src -real 0m1.142s -user 0m1.054s -sys 0m0.090s +real 0m1.093s +user 0m1.013s +sys 0m0.082s =============================================================================== @@ -123,9 +119,9 @@ Test passed. 0 passed and 0 failed. Test passed. -real 0m0.141s -user 0m0.076s -sys 0m0.067s +real 0m0.139s +user 0m0.088s +sys 0m0.053s =============================================================================== @@ -157,43 +153,43 @@ test/classes_test.py::ClassesTest::test_new_aliens_collection PASSED [100%] ---------- coverage: platform linux, python 3.12.1-final-0 ----------- Name Stmts Miss Branch BrPart Cover Missing -------------------------------------------------------- -classes.py 23 0 2 0 100% +classes.py 22 0 2 0 100% -------------------------------------------------------- -TOTAL 23 0 2 0 100% +TOTAL 22 0 2 0 100% Coverage XML written to file .coverage.xml ============================== 10 passed in 0.06s ============================== -real 0m0.844s -user 0m0.734s -sys 0m0.111s +real 0m0.841s +user 0m0.705s +sys 0m0.137s =============================================================================== Running: coverage report --show-missing Name Stmts Miss Branch BrPart Cover Missing -------------------------------------------------------- -classes.py 23 0 2 0 100% +classes.py 22 0 2 0 100% -------------------------------------------------------- -TOTAL 23 0 2 0 100% +TOTAL 22 0 2 0 100% -real 0m0.180s -user 0m0.115s -sys 0m0.068s +real 0m0.162s +user 0m0.100s +sys 0m0.064s =============================================================================== coverage annotate -real 0m0.158s -user 0m0.103s -sys 0m0.057s +real 0m0.150s +user 0m0.102s +sys 0m0.049s tail -n 10000 ./*,cover | grep -E -C 3 '^> def |^! ' > def new_aliens_collection(positions: List[Tuple[int, int]]) -> List[Alien]: -> return [Alien(*position) for position in positions] +> """Returns a new list of aliens""" -- > from classes import new_aliens_collection ! except ImportError as err: @@ -211,9 +207,9 @@ tail -n 10000 ./*,cover | grep -E -C 3 '^> def |^! ' Running: misspell ./src/ellens_alien_game/classes.py ./src/ellens_alien_game/__init__.py -real 0m0.023s -user 0m0.021s -sys 0m0.011s +real 0m0.021s +user 0m0.015s +sys 0m0.015s ===============================================================================