Skip to content

Commit 2f8dc0d

Browse files
committed
bumb version to release
Added deprecation warning on the old Query Added `has_filters`, `has_selects`, `has_expands`, `has_search`, `has_order_by` and `clear_filters` to ExperimentalQuery Fixed Folder and Drive `get_child_folders` to work with new ExperimentalQuery
1 parent 952b34f commit 2f8dc0d

File tree

8 files changed

+66
-16
lines changed

8 files changed

+66
-16
lines changed

CHANGES.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,21 @@
22

33
Almost every release features a lot of bugfixes but those are not listed here.
44

5+
## Version 2.1.3 (2025-06-03)
6+
- Calendar: Added the recurrence type (Thanks @RogerSelwyn)
7+
- Calendar: Added the transaction id (Thanks @RogerSelwyn)
8+
- Calendar: Breaking change! Calendar and Schedule get_events method now requires params start_recurring and end_recurring when include_recurring is True.
9+
- Calendar: list_calendars method can now use query objects with select, expand and order by.
10+
- Groups: Added pagination to get_user_groups (Thanks @RogerSelwyn)
11+
- Tasks: Added support for check list items (Thanks @RogerSelwyn)
12+
- Removed Office365 protocol
13+
14+
515
## Version 2.1.2 (2025-04-08)
616
- Calendar: list_calendars now allows pagination (Thanks @RogerSelwyn)
717
- Query: added new experimental Query object that will replace the current Query object in the future. Available in utils.query.
818
- Message: non-draft messages can be saved. This allows to edit non-draft messages.
9-
- Connection: proxies, verify_ssl and timeout are now honored in the msal http client
19+
- Connection: proxies, verify_ssl and timeout are now honored in the msal http client.
1020
- Message: new method `get_eml_as_object` to retrieve attached eml as Message objects.
1121

1222
## Version 2.1.1 (2025-03-20)

O365/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '2.1.2'
1+
__version__ = '2.1.3'

O365/drive.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
ApiComponent,
1515
OneDriveWellKnowFolderNames,
1616
Pagination,
17+
ExperimentalQuery,
18+
CompositeFilter
1719
)
1820

1921
log = logging.getLogger(__name__)
@@ -1185,9 +1187,14 @@ def get_child_folders(self, limit=None, *, query=None, order_by=None, batch=None
11851187

11861188
if query:
11871189
if not isinstance(query, str):
1188-
query = query.on_attribute('folder').unequal(None)
1190+
if isinstance(query, CompositeFilter):
1191+
q = ExperimentalQuery(protocol=self.protocol)
1192+
query = query & q.unequal('folder', None)
1193+
else:
1194+
query = query.on_attribute('folder').unequal(None)
11891195
else:
1190-
query = self.q('folder').unequal(None)
1196+
q = ExperimentalQuery(protocol=self.protocol)
1197+
query = q.unequal('folder', None)
11911198

11921199
return self.get_items(limit=limit, query=query, order_by=order_by, batch=batch)
11931200

@@ -1584,11 +1591,6 @@ def _base_get_list(self, url, limit=None, *, query=None, order_by=None,
15841591
params['$orderby'] = order_by
15851592

15861593
if query:
1587-
# if query.has_filters:
1588-
# warnings.warn(
1589-
# 'Filters are not allowed by the Api Provider '
1590-
# 'in this method')
1591-
# query.clear_filters()
15921594
if isinstance(query, str):
15931595
params['$filter'] = query
15941596
else:
@@ -1650,11 +1652,16 @@ def get_child_folders(self, limit=None, *, query=None, order_by=None, batch=None
16501652
:return: folder items in this folder
16511653
:rtype: generator of DriveItem or Pagination
16521654
"""
1653-
16541655
if query:
1655-
query = query.on_attribute('folder').unequal(None)
1656+
if not isinstance(query, str):
1657+
if isinstance(query, CompositeFilter):
1658+
q = ExperimentalQuery(protocol=self.protocol)
1659+
query = query & q.unequal('folder', None)
1660+
else:
1661+
query = query.on_attribute('folder').unequal(None)
16561662
else:
1657-
query = self.q('folder').unequal(None)
1663+
q = ExperimentalQuery(protocol=self.protocol)
1664+
query = q.unequal('folder', None)
16581665

16591666
return self.get_items(limit=limit, query=query, order_by=order_by, batch=batch)
16601667

O365/utils/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
from .consent import consent_input_token
1010
from .casing import to_snake_case, to_pascal_case, to_camel_case
1111

12-
from .query import QueryBuilder as ExperimentalQuery
12+
from .query import QueryBuilder as ExperimentalQuery, CompositeFilter

O365/utils/query.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import datetime as dt
44
from abc import ABC, abstractmethod
5-
from typing import Union, Optional, TYPE_CHECKING, Type, Iterator, Literal, TypeAlias
5+
from typing import Union, Optional, TYPE_CHECKING, Type, Iterator, TypeAlias
66

77
if TYPE_CHECKING:
88
from O365.connection import Protocol
@@ -376,6 +376,35 @@ def render(self) -> str:
376376
f"Expand: {self.expand.render() if self.expand else ''}"
377377
)
378378

379+
@property
380+
def has_filters(self) -> bool:
381+
""" Returns if this CompositeFilter has filters"""
382+
return self.filters is not None
383+
384+
@property
385+
def has_selects(self) -> bool:
386+
""" Returns if this CompositeFilter has selects"""
387+
return self.select is not None
388+
389+
@property
390+
def has_expands(self) -> bool:
391+
""" Returns if this CompositeFilter has expands"""
392+
return self.expand is not None
393+
394+
@property
395+
def has_search(self) -> bool:
396+
""" Returns if this CompositeFilter has search"""
397+
return self.search is not None
398+
399+
@property
400+
def has_order_by(self) -> bool:
401+
""" Returns if this CompositeFilter has order_by"""
402+
return self.order_by is not None
403+
404+
def clear_filters(self) -> None:
405+
""" Removes all filters from the query """
406+
self.filters = None
407+
379408
@property
380409
def has_only_filters(self) -> bool:
381410
""" Returns true if it only has filters"""

O365/utils/utils.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import datetime as dt
22
import logging
3+
import warnings
34
from collections import OrderedDict
45
from enum import Enum
56
from typing import Dict, Union
@@ -496,6 +497,9 @@ def new_query(self, attribute=None):
496497
:return: new Query
497498
:rtype: Query
498499
"""
500+
warnings.warn('This method will be deprecated in future releases. A new Query object is finished and will be the only option in future releases. '
501+
'Use `from O365.utils import ExperimentalQuery as Query` instead to prepare for this change. '
502+
'Current docs already explain this change. See O365/utils/query.py for more details.', DeprecationWarning)
499503
return Query(attribute=attribute, protocol=self.protocol)
500504

501505
q = new_query # alias for new query

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[project]
22
dynamic = ["license"]
33
name = "o365"
4-
version = "2.1.2"
4+
version = "2.1.3"
55
description = "O365 - Microsoft Graph and Office 365 API made easy"
66
readme = "README.md"
77
requires-python = ">=3.9"

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from setuptools import setup, find_packages
44

55

6-
VERSION = '2.1.2'
6+
VERSION = '2.1.3'
77

88
# Available classifiers: https://pypi.org/pypi?%3Aaction=list_classifiers
99
CLASSIFIERS = [

0 commit comments

Comments
 (0)