Skip to content

Commit

Permalink
Fix __getitem__ implementation, update Travis CI config
Browse files Browse the repository at this point in the history
  • Loading branch information
romis2012 committed Oct 16, 2022
1 parent 6af32c4 commit 83eed2a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
dist: xenial
dist: bionic
sudo: false
language: python

python:
- "3.7"
- "3.8"
- "3.9"
- "3.10"

install:
# to fix https://travis-ci.community/t/build-error-for-python-3-7-on-two-different-projects/12895
- pip install importlib_metadata -U
# - pip install importlib_metadata -U
- pip install -r requirements-dev.txt -U
- pip install -e .

Expand Down
2 changes: 1 addition & 1 deletion pydantic_collections/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
__title__ = 'pydantic-collections'
__version__ = '0.3.0'
__version__ = '0.4.0'

from ._base_collection_model import BaseCollectionModel

Expand Down
5 changes: 4 additions & 1 deletion pydantic_collections/_base_collection_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,10 @@ def __len__(self):
return len(self.__root__)

def __getitem__(self, index):
return self.__root__[index]
if isinstance(index, slice):
return self.__class__(self.__root__[index])
else:
return self.__root__[index]

def __setitem__(self, index, value):
self.__root__[index] = self._validate_element(value, index)
Expand Down

0 comments on commit 83eed2a

Please sign in to comment.