You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix missing f-strings, deprecated datetime, stale pylint directives
- Add f-prefix to three RuntimeError format strings in attributes.py
that were printing literal {self.name} instead of the attribute name
- Replace deprecated datetime.utcnow() with datetime.now(timezone.utc)
in all four export functions
- Update hardcoded version fallback from 1.1.0 to 2.0.0 and narrow
bare except to except Exception in exporters.py
- Remove obsolete pylint no-self-use directives from reporting.py
and iznn/__init__.py
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Performed a full code review of the neat-python codebase, scanning all core modules for defects, typos, stale comments, and quality issues. Identified 11 issues total; fixed 5 in this session.
6
+
7
+
### Fixed: Missing f-string prefixes in attribute validation (attributes.py)
8
+
9
+
Three `raise RuntimeError(...)` calls in `FloatAttribute.validate`, `IntegerAttribute.validate`, and `BoolAttribute.validate` were plain strings instead of f-strings, so error messages would print the literal text `{self.name}` instead of the attribute name.
10
+
11
+
-`neat/attributes.py:89` — FloatAttribute
12
+
-`neat/attributes.py:133` — IntegerAttribute
13
+
-`neat/attributes.py:177` — BoolAttribute
14
+
15
+
### Fixed: Hardcoded fallback version and bare except in exporters (export/exporters.py)
16
+
17
+
`_get_neat_version()` had a hardcoded fallback of `"1.1.0"` but the project version is `2.0.0`. Also used a bare `except:` clause which catches SystemExit, KeyboardInterrupt, etc. Changed fallback to `"2.0.0"` and narrowed to `except Exception:`.
18
+
19
+
### Fixed: Deprecated datetime.utcnow() in exporters (export/exporters.py)
20
+
21
+
All four exporter functions (`export_feedforward`, `export_recurrent`, `export_ctrnn`, `export_iznn`) used `datetime.utcnow().isoformat() + "Z"` which is deprecated since Python 3.12. Replaced with `datetime.now(timezone.utc).isoformat()` which produces a timezone-aware ISO 8601 string with `+00:00` suffix.
1.**Destructive pickling side effects** — `DefaultGenomeConfig.__getstate__` and `DefaultSpeciesSet.__getstate__` call `next()` on `itertools.count` objects, advancing the counter on the original object.
33
+
2.**FeedForwardNetwork.create mutates genome** — Writing to `cg.weight` when `random_values` or `unique_value` is set corrupts the genome. Also `if unique_value:` is falsy for 0.0.
34
+
3.**best_genome tracking ignores fitness_criterion** — Always uses `>` even when `fitness_criterion = min`.
35
+
4.**fitness_criterion attribute may not be set** — When `no_fitness_termination=True` and criterion is not max/min/mean.
36
+
5.**Dead None check in stagnation.py:56** — `prev_fitness` can never be None.
37
+
6.**Weaker connection filter in RecurrentNetwork/CTRNN** — Should match the stricter filter used by IZNN.
0 commit comments