remove some pre-3.8 workarounds (#7671)

This commit is contained in:
Mike Fährmann
2025-06-17 12:56:47 +02:00
parent d0b1da0fa7
commit 6d928f3805
7 changed files with 8 additions and 37 deletions

View File

@@ -45,10 +45,7 @@ jobs:
- name: Install yt-dlp
run: |
case "${{ matrix.python-version }}" in
3.4|3.5)
# don't install yt-dlp
;;
3.6|3.7|3.8)
3.8)
# install from PyPI
pip install yt-dlp
;;
@@ -60,14 +57,7 @@ jobs:
- name: Lint with flake8
run: |
case "${{ matrix.python-version }}" in
3.4|3.5|3.6|3.7)
flake8 --extend-exclude scripts/export_tests.py,scripts/pyprint.py .
;;
*)
flake8 .
;;
esac
flake8 .
- name: Run tests
run: |

View File

@@ -78,8 +78,8 @@ Description
If this is an ``object``, it must contain Python expressions mapping to the
filename format strings to use.
These expressions are evaluated in the order as specified in Python 3.6+
and in an undetermined order in Python 3.4 and 3.5.
These expressions are evaluated in the specified order until one evaluates
to ``True``.
The available replacement keys depend on the extractor used. A list
of keys for a specific one can be acquired by calling *gallery-dl*

View File

@@ -317,12 +317,7 @@ else:
def parse_datetime(date_string, format="%Y-%m-%dT%H:%M:%S%z", utcoffset=0):
"""Create a datetime object by parsing 'date_string'"""
try:
if format.endswith("%z") and date_string[-3] == ":":
# workaround for Python < 3.7: +00:00 -> +0000
ds = date_string[:-3] + date_string[-2:]
else:
ds = date_string
d = datetime.datetime.strptime(ds, format)
d = datetime.datetime.strptime(date_string, format)
o = d.utcoffset()
if o is not None:
# convert to naive UTC

View File

@@ -198,7 +198,6 @@ class TestExtractorModule(unittest.TestCase):
extr.initialize()
extr.finalize()
@unittest.skipIf(sys.hexversion < 0x3060000, "test fails in CI")
def test_init_ytdl(self):
try:
extr = extractor.find("ytdl:")

View File

@@ -66,10 +66,7 @@ class TestFormatter(unittest.TestCase):
self._run_test("{t!d}", datetime.datetime(2010, 1, 1))
self._run_test("{t!d:%Y-%m-%d}", "2010-01-01")
self._run_test("{t!D}" , datetime.datetime(2010, 1, 1))
if sys.hexversion >= 0x3070000:
self._run_test("{ds!D}", datetime.datetime(2010, 1, 1))
else:
self._run_test("{ds!D}", datetime.datetime(1970, 1, 1))
self._run_test("{ds!D}", datetime.datetime(2010, 1, 1))
self._run_test("{dt!D}", datetime.datetime(2010, 1, 1))
self._run_test("{t!D:%Y-%m-%d}", "2010-01-01")
self._run_test("{dt!T}", "1262304000")
@@ -427,7 +424,6 @@ class TestFormatter(unittest.TestCase):
self._run_test("\fE name * 2 + ' ' + a", "{}{} {}".format(
self.kwdict["name"], self.kwdict["name"], self.kwdict["a"]))
@unittest.skipIf(sys.hexversion < 0x3060000, "no fstring support")
def test_fstring(self):
self._run_test("\fF {a}", self.kwdict["a"])
self._run_test("\fF {name}{name} {a}", "{}{} {}".format(
@@ -435,7 +431,6 @@ class TestFormatter(unittest.TestCase):
self._run_test("\fF foo-'\"{a.upper()}\"'-bar",
"""foo-'"{}"'-bar""".format(self.kwdict["a"].upper()))
@unittest.skipIf(sys.hexversion < 0x3060000, "no fstring support")
def test_template_fstring(self):
with tempfile.TemporaryDirectory() as tmpdirname:
path1 = os.path.join(tmpdirname, "tpl1")

View File

@@ -377,9 +377,7 @@ class MetadataTest(BasePostprocessorTest):
path = self.pathfmt.realpath + ".JSON"
m.assert_called_once_with(path, "w", encoding="utf-8")
if sys.hexversion >= 0x3060000:
# python 3.4 & 3.5 have random order without 'sort: True'
self.assertEqual(self._output(m), """{
self.assertEqual(self._output(m), """{
"category": "test",
"filename": "file",
"extension": "ext",

View File

@@ -794,8 +794,6 @@ value = 123
self.assertEqual(f(["a", "b", "c"]), "a, b, c")
self.assertEqual(f([1, 2, 3]), "1, 2, 3")
@unittest.skipIf(sys.hexversion < 0x3070000,
"datetime.fromisoformat")
def test_to_datetime(self, f=util.to_datetime):
def _assert(value, expected):
@@ -1017,11 +1015,7 @@ value = 123
self.assertIsNot(p1, p2)
self.assertIs(p2, p3)
if sys.hexversion >= 0x3060000:
self.assertEqual(p1, p2)
else:
self.assertEqual(repr(p1), repr(p2))
self.assertEqual(p1, p2)
class TestExtractor():