Skip to content

Commit

Permalink
Drop support for Python 3.8; XBlock <2
Browse files Browse the repository at this point in the history
Additionally, use generative section names in tox.ini by prefixing
*all* our testenvs with the Python version factor
("py311", "py312", etc.), we can ensure that all of our testenvs can
be invoked with either Python version being present on the system.
  • Loading branch information
Maari Tamm committed Oct 11, 2024
1 parent 89f0d27 commit 4acdf11
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/sh
exec tox -e flake8
exec tox -e py311-flake8,py312-flake8
10 changes: 3 additions & 7 deletions .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,10 @@ jobs:
strategy:
matrix:
python-version:
- '3.8'
- '3.11'
- '3.12'
pip-version:
- 22.0.4
- 23.2.1
include:
- python-version: '3.12'
pip-version: '23.2.1'

steps:
- name: Check out code
Expand Down Expand Up @@ -50,10 +46,10 @@ jobs:
uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
- name: Set up Python 3.8
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: 3.8
python-version: 3.11
- name: Install dependencies
run: |
pip install coverage
Expand Down
27 changes: 6 additions & 21 deletions markdown_xblock/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,10 @@
from django.conf import settings as django_settings
from xblock.core import XBlock
from xblock.fields import List, Scope, String
try: # XBlock 2+
from web_fragments.fragment import Fragment
from xblock.utils.resources import ResourceLoader
from xblock.utils.settings import XBlockWithSettingsMixin
from xblock.utils.studio_editable import StudioEditableXBlockMixin, loader
except ImportError: # Compatibility with XBlock<2
from xblock.fragment import Fragment
from xblockutils.resources import ResourceLoader
from xblockutils.settings import XBlockWithSettingsMixin
from xblockutils.studio_editable import StudioEditableXBlockMixin, loader
from web_fragments.fragment import Fragment
from xblock.utils.resources import ResourceLoader
from xblock.utils.settings import XBlockWithSettingsMixin
from xblock.utils.studio_editable import StudioEditableXBlockMixin, loader

from .utils import _

Expand Down Expand Up @@ -282,21 +276,12 @@ def get_editable_fields(self):
return fields

@classmethod
def parse_xml(cls, node, runtime, keys, id_generator=None):
def parse_xml(cls, node, runtime, keys):
"""
Use `node` to construct a new block.
"""
block = runtime.construct_xblock_from_class(cls, keys)

# Prior to XBlock 2.0, id_generator is passed in.
# Since XBlock 2.0, we grab it from the runtime.
#
# TODO: Once we decide to drop support for versions prior to
# XBlock 2 (i.e. Open edX releases before Redwood), we can
# drop id_generator from the method signature, and always rely
# on runtime.id_generator.
if not id_generator:
id_generator = runtime.id_generator
id_generator = runtime.id_generator

# Read markdown content from file and add to editor.
url_name = node.get('url_name', node.get('slug'))
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ def package_data(pkg, roots):
packages=[
'markdown_xblock',
],
python_requires='>=3.11',
install_requires=[
'XBlock<2; python_version < "3.9"',
'XBlock<5; python_version >= "3.9"',
'XBlock<5',
'markdown2>=2.3.9',
'Pygments>=2.0.1',
],
Expand Down
13 changes: 6 additions & 7 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
[tox]
envlist = py{38,311,312},pipdeptree{,-requirements},flake8,report
envlist = py{311,312}{,-pipdeptree,-pipdeptree-requirements,-flake8},report

[gh-actions]
python =
3.8: py38,pipdeptree{,-requirements},flake8
3.11: py311,pipdeptree{,-requirements},flake8
3.12: py312,pipdeptree{,-requirements},flake8
3.11: py311{,-pipdeptree,-pipdeptree-requirements,-flake8}
3.12: py312{,-pipdeptree,-pipdeptree-requirements,-flake8}

[flake8]
ignore = E124
Expand All @@ -27,18 +26,18 @@ deps =
-rrequirements/base.txt
-rrequirements/test.txt

[testenv:pipdeptree]
[testenv:py{311,312}-pipdeptree]
deps =
pipdeptree
commands = pipdeptree -w fail

[testenv:pipdeptree-requirements]
[testenv:py{311,312}-pipdeptree-requirements]
deps =
-rrequirements/base.txt
pipdeptree
commands = pipdeptree -w fail

[testenv:flake8]
[testenv:py{311,312}-flake8]
deps = flake8
commands = flake8

Expand Down

0 comments on commit 4acdf11

Please sign in to comment.