From 05c18db1e7bca8dcf7a23c866cba6ed51dd39a22 Mon Sep 17 00:00:00 2001 From: Hans Spaans <1072510+hspaans@users.noreply.github.com> Date: Thu, 3 Sep 2026 21:51:54 +0000 Subject: [PATCH 1/2] Bump Python version to 3.12, remove 3.11, and add pyupgrade for code modernization --- .github/workflows/ci.yml | 1 - .gitignore | 2 +- .python-version | 1 + pyproject.toml | 16 ++++++++++++++-- src/m6502/processor.py | 6 ++---- 5 files changed, 18 insertions(+), 8 deletions(-) create mode 100644 .python-version diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fa612a4..15ae0cb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,6 @@ jobs: - "3.14" - "3.13" - "3.12" - - "3.11" steps: - name: Setup python for test ${{ matrix.py }} uses: actions/setup-python@v7 diff --git a/.gitignore b/.gitignore index 2d263f2..5a38523 100644 --- a/.gitignore +++ b/.gitignore @@ -83,7 +83,7 @@ profile_default/ ipython_config.py # pyenv -.python-version +#.python-version # pipenv # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..fdcfcfd --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.12 \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 7b881d8..82d4033 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,7 +13,6 @@ classifiers = [ "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", "Programming Language :: Python :: 3.14", @@ -62,6 +61,7 @@ lint = [ "flake8-rst-docstrings", "flake8-isort", "pymarkdownlnt", + "pyupgrade", "rstcheck", "yamllint", ] @@ -111,7 +111,7 @@ skips = ["B101", "B601", "S101"] [tool.tox] requires = ["tox>=4.52.1,<5.0.0"] -env_list = ["lint", "fix", "3.14", "3.13", "3.12", "3.11", "cov", "type", "pkg_meta"] +env_list = ["lint", "fix", "3.14", "3.13", "3.12", "cov", "type", "pkg_meta"] skip_missing_interpreters = true [tool.tox.env_run_base] @@ -155,3 +155,15 @@ commands = [ ["pymarkdownlnt", "scan", "."], ["python", "-c", 'print(r"{env_python}")'], ] + +[tool.tox.env.fix] +description = "running pyupgrade at {envdir}" +package = "editable" +dependency_groups = ["lint", "test"] +allowlist_externals = ["git", "sh"] +commands = [ + # Finds all tracked .py files and updates them to Python 3.12+ syntax + ["sh", "-c", "git ls-files '*.py' | xargs pyupgrade --py312-plus"], + # Fails the build if pyupgrade modified any files (perfect for CI) + ["git", "diff", "--exit-code"] +] diff --git a/src/m6502/processor.py b/src/m6502/processor.py index 6018b44..321bf36 100644 --- a/src/m6502/processor.py +++ b/src/m6502/processor.py @@ -777,7 +777,7 @@ def _ins_lda_inx(self) -> None: The instruction costs 2 bytes and 6 cycles to complete. """ self.reg_a = self._read_byte( - self._read_word(((self._fetch_byte() + self.reg_x) & 0xFF)) + self._read_word((self._fetch_byte() + self.reg_x) & 0xFF) ) self._evaluate_flags_nz(self.reg_a) self.cycles += 1 # TODO: Why is the extra cycle required? @@ -1261,9 +1261,7 @@ def _ins_sta_inx(self) -> None: The instruction costs 2 bytes and 6 cycles to complete. """ self._write_byte( - self._read_byte( - self._read_word(((self._fetch_byte() + self.reg_x) & 0xFF)) - ), + self._read_byte(self._read_word((self._fetch_byte() + self.reg_x) & 0xFF)), self.reg_a, ) From b791b8e8e85bda4bf7da45e7839954e348a13b55 Mon Sep 17 00:00:00 2001 From: Hans Spaans <1072510+hspaans@users.noreply.github.com> Date: Thu, 3 Sep 2026 22:10:15 +0000 Subject: [PATCH 2/2] Update required Python version to 3.12 in pyproject.toml --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 82d4033..ecf93ff 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,7 +26,7 @@ maintainers = [ {name="Hans Spaans", email="hspaans@gmail.com"}, ] -requires-python = ">= 3.11,<3.15" +requires-python = ">= 3.12,<3.15" dependencies = [ ]