Skip to content

Commit 95f6b1f

Browse files
authored
Merge pull request #271 from jacebrowning/drop-3.7
Drop support for Python 3.7
2 parents 619725e + 2c832fd commit 95f6b1f

8 files changed

Lines changed: 69 additions & 110 deletions

File tree

.verchew.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ version = GNU Make
66
[Python]
77

88
cli = python
9-
version = 3.7 || 3.8 || 3.9 || 3.10
9+
version = 3.8 || 3.9 || 3.10
1010

1111
[Poetry]
1212

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# Release Notes
22

3+
## 2.0 (alpha)
4+
5+
- Dropped support for Python 3.7.
6+
37
## 1.4.3 (2022-08-19)
48

5-
- Fixed handling of unparseable YAML files in manager methods.
9+
- Fixed handling of invalid YAML files in manager methods.
610

711
## 1.4.2 (2022-07-29)
812

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ Objects can also be restored from the filesystem:
101101

102102
## Installation
103103

104-
Because datafiles relies on dataclasses and type annotations, Python 3.7+ is required. Install this library directly into an activated virtual environment:
104+
Install this library directly into an activated virtual environment:
105105

106106
```
107107
$ pip install datafiles

datafiles/manager.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import log
1414
from parse import parse
1515
from ruamel.yaml.parser import ParserError
16+
from ruamel.yaml.scanner import ScannerError
1617

1718
from . import hooks
1819

@@ -43,8 +44,10 @@ def get(self, *args, **kwargs) -> Model:
4344
instance = self.model(*args, **kwargs)
4445
try:
4546
instance.datafile.load()
46-
except ParserError:
47-
log.critical(f"Deleting unparseable YAML: {instance.datafile.path}")
47+
except (ParserError, ScannerError) as e:
48+
log.critical(
49+
f"Deleting invalid YAML: {instance.datafile.path} ({e.problem})"
50+
)
4851
instance.datafile.path.unlink()
4952
instance.datafile.load()
5053

datafiles/tests/test_converters.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22

33
from dataclasses import dataclass
44
from enum import Enum
5-
from typing import ByteString, Dict, List, Mapping, Optional, Set, Union
5+
from typing import ByteString, Dict, List, Mapping, Optional, Set, TypedDict, Union
66

77
import pytest
88
from ruamel.yaml.scalarstring import LiteralScalarString
9-
from typing_extensions import TypedDict
109

1110
from datafiles import converters, settings
1211

datafiles/tests/test_manager.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ def when_file_missing(expect, manager):
5252
def when_file_corrupt(expect, manager):
5353
instance = manager.get_or_create(foo=2, bar=1)
5454
instance.datafile.path.write_text("{")
55-
instance = manager.get_or_none(foo=2, bar=2)
56-
expect(instance).is_(None)
55+
instance2 = manager.get_or_none(foo=2, bar=2)
56+
expect(instance2).is_(None)
57+
expect(instance.datafile.path.is_file()).is_(False)
5758

5859
def describe_get_or_create():
5960
@patch("datafiles.mapper.Mapper.save")
@@ -76,8 +77,8 @@ def when_file_missing(mock_save, mock_load, expect, manager):
7677
def when_file_corrupt(expect, manager):
7778
instance = manager.get_or_create(foo=2, bar=1)
7879
instance.datafile.path.write_text("{")
79-
instance = manager.get_or_create(foo=2, bar=2)
80-
expect(instance.bar) == 2
80+
instance2 = manager.get_or_create(foo=2, bar=2)
81+
expect(instance2.bar) == 2
8182

8283
def describe_all():
8384
@patch("datafiles.mapper.Mapper.exists", False)

0 commit comments

Comments
 (0)