Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Backlog/remove python 2 traces #35

Merged
merged 18 commits into from Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/cicd.yml
Expand Up @@ -9,6 +9,12 @@ on:

pull_request:


concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true


jobs:
check-formatting:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion pyproject.toml
Expand Up @@ -33,7 +33,6 @@ pyparsing = ">=2.0,<3"
clique = "==1.6.1"
websocket-client = ">=0.40.0,<1"
future = ">=0.16.0,<1"
six = ">=1.13.0,<2"
platformdirs = ">=4.0.0,<5"
wheel = "^0.41.2"

Expand Down
2 changes: 1 addition & 1 deletion source/ftrack_api/_version.py
@@ -1,2 +1,2 @@
# These version placeholders will be replaced later during substitution.
__version__ = "0.0.1.dev"
__version__ = "3.0.0rc1.post1.dev0+3a424f3"
torsdag marked this conversation as resolved.
Show resolved Hide resolved
66 changes: 0 additions & 66 deletions source/ftrack_api/_weakref.py

This file was deleted.

4 changes: 1 addition & 3 deletions source/ftrack_api/accessor/base.py
@@ -1,14 +1,12 @@
# :coding: utf-8
# :copyright: Copyright (c) 2013 ftrack

from builtins import object
import abc

import ftrack_api.exception
from future.utils import with_metaclass


class Accessor(with_metaclass(abc.ABCMeta, object)):
class Accessor(metaclass=abc.ABCMeta):
"""Provide data access to a location.

A location represents a specific storage, but access to that storage may
Expand Down
7 changes: 3 additions & 4 deletions source/ftrack_api/attribute.py
Expand Up @@ -4,8 +4,7 @@
from __future__ import absolute_import

from builtins import object
import collections
from six.moves import collections_abc
import collections.abc
import copy
import logging
import functools
Expand Down Expand Up @@ -538,7 +537,7 @@ def _adapt_to_collection(self, entity, value):
value, self.creator, self.key_attribute, self.value_attribute
)

elif isinstance(value, collections_abc.Mapping):
elif isinstance(value, collections.abc.Mapping):
# Convert mapping.
# TODO: When backend model improves, revisit this logic.
# First get existing value and delete all references. This is
Expand Down Expand Up @@ -612,7 +611,7 @@ def _adapt_to_collection(self, entity, value):

value = ftrack_api.collection.CustomAttributeCollectionProxy(value)

elif isinstance(value, collections_abc.Mapping):
elif isinstance(value, collections.abc.Mapping):
# Convert mapping.
# TODO: When backend model improves, revisit this logic.
# First get existing value and delete all references. This is
Expand Down
36 changes: 9 additions & 27 deletions source/ftrack_api/cache.py
Expand Up @@ -16,42 +16,24 @@
"""

from builtins import str
from six import string_types
from builtins import object
from six.moves import collections_abc
import functools
import abc
import collections.abc
import copy
import inspect
import re

try:
# Python 2.x
import anydbm
except ImportError:
import dbm as anydbm


import pickle
import contextlib
from future.utils import with_metaclass

try:
try:
import _pickle as pickle
except:
import six
from six.moves import cPickle as pickle
except:
try:
import cPickle as pickle
except:
import pickle

import dbm as anydbm

import ftrack_api.inspection
import ftrack_api.symbol


class Cache(with_metaclass(abc.ABCMeta, object)):
class Cache(metaclass=abc.ABCMeta):
"""Cache interface.

Derive from this to define concrete cache implementations. A cache is
Expand Down Expand Up @@ -378,7 +360,7 @@ def set(self, key, value):
super(SerialisedCache, self).set(key, value)


class KeyMaker(with_metaclass(abc.ABCMeta, object)):
class KeyMaker(metaclass=abc.ABCMeta):
"""Generate unique keys."""

def __init__(self):
Expand Down Expand Up @@ -454,11 +436,11 @@ def __key(self, item):

# TODO: Consider using a more robust and comprehensive solution such as
# dill (https://github.com/uqfoundation/dill).
if isinstance(item, collections_abc.Iterable):
if isinstance(item, string_types):
if isinstance(item, collections.abc.Iterable):
if isinstance(item, str):
return pickle.dumps(item, pickle_protocol)

if isinstance(item, collections_abc.Mapping):
if isinstance(item, collections.abc.Mapping):
contents = self.item_separator.join(
[
(
Expand Down
7 changes: 3 additions & 4 deletions source/ftrack_api/collection.py
Expand Up @@ -7,8 +7,7 @@
from builtins import str
import logging

import collections
from six.moves import collections_abc
import collections.abc
import copy

import ftrack_api.exception
Expand All @@ -19,7 +18,7 @@
from ftrack_api.logging import LazyLogMessage as L


class Collection(collections_abc.MutableSequence):
class Collection(collections.abc.MutableSequence):
"""A collection of entities."""

def __init__(self, entity, attribute, mutable=True, data=None):
Expand Down Expand Up @@ -152,7 +151,7 @@ def __ne__(self, other):
return not self == other


class MappedCollectionProxy(collections_abc.MutableMapping):
class MappedCollectionProxy(collections.abc.MutableMapping):
"""Common base class for mapped collection of entities."""

def __init__(self, collection):
Expand Down
3 changes: 1 addition & 2 deletions source/ftrack_api/data.py
Expand Up @@ -5,10 +5,9 @@
import os
from abc import ABCMeta, abstractmethod
import tempfile
from future.utils import with_metaclass


class Data(with_metaclass(ABCMeta, object)):
class Data(metaclass=ABCMeta):
"""File-like object for manipulating data."""

def __init__(self):
Expand Down
8 changes: 2 additions & 6 deletions source/ftrack_api/entity/base.py
Expand Up @@ -5,8 +5,7 @@

from builtins import str
import abc
import collections
from six.moves import collections_abc
import collections.abc
import logging

import ftrack_api.symbol
Expand All @@ -15,7 +14,6 @@
import ftrack_api.exception
import ftrack_api.operation
from ftrack_api.logging import LazyLogMessage as L
from future.utils import with_metaclass


class _EntityBase(object):
Expand All @@ -39,9 +37,7 @@ def __repr__(self):


class Entity(
with_metaclass(
DynamicEntityTypeMetaclass, _EntityBase, collections_abc.MutableMapping
)
_EntityBase, collections.abc.MutableMapping, metaclass=DynamicEntityTypeMetaclass
):
"""Base class for all entities."""

Expand Down
36 changes: 18 additions & 18 deletions source/ftrack_api/entity/location.py
Expand Up @@ -2,10 +2,7 @@
# :copyright: Copyright (c) 2015 ftrack

from builtins import zip
from six import string_types
from builtins import object
import collections
from six.moves import collections_abc
import collections.abc
import functools

import ftrack_api.entity.base
Expand All @@ -15,15 +12,6 @@
import ftrack_api.inspection
from ftrack_api.logging import LazyLogMessage as L

from future.utils import with_metaclass


MixinBaseClass = with_metaclass(
ftrack_api.entity.base.DynamicEntityTypeMetaclass,
ftrack_api.entity.base._EntityBase,
collections_abc.MutableMapping,
)


class Location(ftrack_api.entity.base.Entity):
"""Represent storage for components."""
Expand Down Expand Up @@ -129,8 +117,8 @@ def add_components(self, components, sources, recursive=True, _depth=0):
issues and any transferred data under the 'transferred' detail key.

"""
if isinstance(sources, string_types) or not isinstance(
sources, collections_abc.Sequence
if isinstance(sources, str) or not isinstance(
sources, collections.abc.Sequence
):
sources = [sources]

Expand Down Expand Up @@ -590,7 +578,11 @@ def get_url(self, component):
return self.accessor.get_url(resource_identifier)


class MemoryLocationMixin(MixinBaseClass):
class MemoryLocationMixin(
ftrack_api.entity.base._EntityBase,
collections.abc.MutableMapping,
metaclass=ftrack_api.entity.base.DynamicEntityTypeMetaclass,
):
"""Represent storage for components.

Unlike a standard location, only store metadata for components in this
Expand Down Expand Up @@ -652,7 +644,11 @@ def _get_resource_identifiers(self, components):
return resource_identifiers


class UnmanagedLocationMixin(MixinBaseClass):
class UnmanagedLocationMixin(
ftrack_api.entity.base._EntityBase,
collections.abc.MutableMapping,
metaclass=ftrack_api.entity.base.DynamicEntityTypeMetaclass,
):
"""Location that does not manage data."""

def _add_data(self, component, resource_identifier, source):
Expand Down Expand Up @@ -687,7 +683,11 @@ def _get_context(self, component, source):
return context


class ServerLocationMixin(MixinBaseClass):
class ServerLocationMixin(
ftrack_api.entity.base._EntityBase,
collections.abc.MutableMapping,
metaclass=ftrack_api.entity.base.DynamicEntityTypeMetaclass,
):
"""Location representing ftrack server.

Adds convenience methods to location, specific to ftrack server.
Expand Down
4 changes: 2 additions & 2 deletions source/ftrack_api/event/base.py
Expand Up @@ -3,10 +3,10 @@

from builtins import str
import uuid
from six.moves import collections_abc
import collections.abc


class Event(collections_abc.MutableMapping):
class Event(collections.abc.MutableMapping):
"""Represent a single event."""

def __init__(
Expand Down
3 changes: 1 addition & 2 deletions source/ftrack_api/event/expression.py
Expand Up @@ -2,7 +2,6 @@
# :copyright: Copyright (c) 2014 ftrack

from builtins import map
from six import string_types
from builtins import object
from operator import eq, ne, ge, le, gt, lt

Expand Down Expand Up @@ -266,7 +265,7 @@ def match(self, candidate):

if (
self._operator is eq
and isinstance(self._value, string_types)
and isinstance(self._value, str)
and self._value[-1] == self._wildcard
):
return self._value[:-1] in value
Expand Down