Repository: OpenAssetIO/OpenAssetIO (language: python)

Issue:
Remove deprecated aliases
## What

Remove old deprecated aliases/types of `TraitsData`, `BatchElementError` and `BatchElementException`

## Why

These are old enough now that we can remove them, at the very least for v1.0.0.

## Acceptance Criteria

Remove old deprecated aliases/types of `TraitsData`, `BatchElementError` and `BatchElementException`
Make sure downstream projects still work with these aliases removed.


Discussion / hints:

Fix patch:
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md
index 7c83a50c3..1042bd812 100644
--- a/RELEASE_NOTES.md
+++ b/RELEASE_NOTES.md
@@ -15,6 +15,15 @@ section for more details._
   version is now Python 3.9.
   [#1365](https://github.com/OpenAssetIO/OpenAssetIO/pull/1365)
 
+- Removed deprecated type aliases `openassetio.TraitsData`,
+  `openassetio.BatchElementError`
+  and `openassetio.BatchElementException`.
+  Removed the deprecated explicit `*BatchElementException` exception
+  subtypes under the top-level `openassetio` namespace. Removed the
+  deprecated Python `openassetio.exceptions` module. Removed the
+  deprecated `kField_*` constants.
+  [#1311](https://github.com/OpenAssetIO/OpenAssetIO/issues/1311)
+
 - Marked as "final" several C++ Python bindings of classes that do not
   support Python inheritance, such that an error will be encountered at
   import time if an attempt is made to inherit from them.
diff --git a/src/openassetio-core/CMakeLists.txt b/src/openassetio-core/CMakeLists.txt
index e9e67b881..b208b130d 100644
--- a/src/openassetio-core/CMakeLists.txt
+++ b/src/openassetio-core/CMakeLists.txt
@@ -62,7 +62,6 @@ endif ()
 target_sources(
     openassetio-core
     PRIVATE
-    src/BatchElementError.cpp
     src/Context.cpp
     src/errors/exceptionMessages.cpp
     src/hostApi/HostInterface.cpp
diff --git a/src/openassetio-core/include/openassetio/BatchElementError.hpp b/src/openassetio-core/include/openassetio/BatchElementError.hpp
deleted file mode 100644
index 8e9a7be30..000000000
--- a/src/openassetio-core/include/openassetio/BatchElementError.hpp
+++ /dev/null
@@ -1,68 +0,0 @@
-// SPDX-License-Identifier: Apache-2.0
-// Copyright 2023 The Foundry Visionmongers Ltd
-#pragma once
-
-#include <openassetio/export.h>
-#include <openassetio/errors/BatchElementError.hpp>
-#include <openassetio/errors/exceptions.hpp>
-
-// Deprecated:
-//  https://github.com/OpenAssetIO/OpenAssetIO/issues/1071
-//  https://github.com/OpenAssetIO/OpenAssetIO/issues/1073
-
-namespace openassetio {
-inline namespace OPENASSETIO_CORE_ABI_VERSION {
-// 'typedef' allows attributes, 'using' does not
-/// @deprecated see @fqref{errors.BatchElementError} "errors::BatchElementError"
-// NOLINTNEXTLINE
-OPENASSETIO_CORE_DEPRECATED typedef errors::BatchElementError BatchElementError;
-
-/// @deprecated see @fqref{errors.BatchElementException}
-struct OPENASSETIO_CORE_DEPRECATED_EXPORT BatchElementException : errors::BatchElementException {
-  BatchElementException(std::size_t idx, errors::BatchElementError err)  // NOLINT
-      : errors::BatchElementException(idx, err, err.message) {}
-};
-
-/// @deprecated Removed, use @fqref{errors.BatchElementException} "errors::BatchElementException"
-struct OPENASSETIO_CORE_DEPRECATED_EXPORT UnknownBatchElementException : BatchElementException {
-  using BatchElementException::BatchElementException;
-};
-
-/// @deprecated Removed, use @fqref{errors.BatchElementException} "errors::BatchElementException"
-struct OPENASSETIO_CORE_DEPRECATED_EXPORT InvalidEntityReferenceBatchElementException
-    : BatchElementException {
-  using BatchElementException::BatchElementException;
-};
-
-/// @deprecated Removed, use @fqref{errors.BatchElementException} "errors::BatchElementException"
-
-struct OPENASSETIO_CORE_DEPRECATED_EXPORT MalformedEntityReferenceBatchElementException
-    : BatchElementException {
-  using BatchElementException::BatchElementException;
-};
-
-/// @deprecated Removed, use @fqref{errors.BatchElementException} "errors::BatchElementException"
-struct OPENASSETIO_CORE_DEPRECATED_EXPORT EntityAccessErrorBatchElementException
-    : BatchElementException {
-  using BatchElementException::BatchElementException;
-};
-
-/// @deprecated Removed, use @fqref{errors.BatchElementException} "errors::BatchElementException"
-struct OPENASSETIO_CORE_DEPRECATED_EXPORT EntityResolutionErrorBatchElementException
-    : BatchElementException {
-  using BatchElementException::BatchElementException;
-};
-
-/// @deprecated Removed, use @fqref{errors.BatchElementException} "errors::BatchElementException"
-struct OPENASSETIO_CORE_DEPRECATED_EXPORT InvalidPreflightHintBatchElementException
-    : BatchElementException {
-  using BatchElementException::BatchElementException;
-};
-
-/// @deprecated Removed, use @fqref{errors.BatchElementException} "errors::BatchElementException"
-struct OPENASSETIO_CORE_DEPRECATED_EXPORT InvalidTraitSetBatchElementException
-    : BatchElementException {
-  using BatchElementException::BatchElementException;
-};
-}  // namespace OPENASSETIO_CORE_ABI_VERSION
-}  // namespace openassetio
diff --git a/src/openassetio-core/include/openassetio/TraitsData.hpp b/src/openassetio-core/include/openassetio/TraitsData.hpp
deleted file mode 100644
index cf0eb33b0..000000000
--- a/src/openassetio-core/include/openassetio/TraitsData.hpp
+++ /dev/null
@@ -1,16 +0,0 @@
-// SPDX-License-Identifier: Apache-2.0
-// Copyright 2023 The Foundry Visionmongers Ltd
-#pragma once
-
-// Deprecated: https://github.com/OpenAssetIO/OpenAssetIO/issues/1127
-
-#include <openassetio/trait/TraitsData.hpp>
-
-namespace openassetio {
-inline namespace OPENASSETIO_CORE_ABI_VERSION {
-// 'typedef' allows attributes, 'using' does not
-[[deprecated("Moved to 'trait' namespace")]] typedef trait::TraitsData TraitsData;        // NOLINT
-[[deprecated("Moved to 'trait' namespace")]] typedef trait::TraitsDataPtr TraitsDataPtr;  // NOLINT
-// NOLINTEND
-}  // namespace OPENASSETIO_CORE_ABI_VERSION
-}  // namespace openassetio
diff --git a/src/openassetio-core/src/BatchElementError.cpp b/src/openassetio-core/src/BatchElementError.cpp
deleted file mode 100644
index d0912e759..000000000
--- a/src/openassetio-core/src/BatchElementError.cpp
+++ /dev/null
@@ -1,12 +0,0 @@
-// SPDX-License-Identifier: Apache-2.0
-// Copyright 2023 The Foundry Visionmongers Ltd
-#if defined(__clang__)
-#pragma clang diagnostic ignored "-Wdeprecated-declarations"
-#elif defined(__GNUC__)
-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-#endif
-
-#include <openassetio/BatchElementError.hpp>
-
-// This file exists soley to ensure the symbol is used to
-// ensure it is present in the library on windows.
diff --git a/src/openassetio-python/cmodule/src/constantsBinding.cpp b/src/openassetio-python/cmodule/src/constantsBinding.cpp
index 0aa409f24..097c62842 100644
--- a/src/openassetio-python/cmodule/src/constantsBinding.cpp
+++ b/src/openassetio-python/cmodule/src/constantsBinding.cpp
@@ -12,9 +12,4 @@ void registerConstants(const py::module_ &mod) {
   mod.attr("kInfoKey_SmallIcon") = openassetio::constants::kInfoKey_SmallIcon;
   mod.attr("kInfoKey_EntityReferencesMatchPrefix") =
       openassetio::constants::kInfoKey_EntityReferencesMatchPrefix;
-  // TODO(DF): @deprecated
-  mod.attr("kField_Icon") = openassetio::constants::kInfoKey_Icon;
-  mod.attr("kField_SmallIcon") = openassetio::constants::kInfoKey_SmallIcon;
-  mod.attr("kField_EntityReferencesMatchPrefix") =
-      openassetio::constants::kInfoKey_EntityReferencesMatchPrefix;
 }
diff --git a/src/openassetio-python/package/openassetio/__init__.py b/src/openassetio-python/package/openassetio/__init__.py
index 565be98af..a1b189454 100644
--- a/src/openassetio-python/package/openassetio/__init__.py
+++ b/src/openassetio-python/package/openassetio/__init__.py
@@ -88,37 +88,3 @@
     betaMinorVersion,
     versionString,
 )
-
-
-#
-# Deprecated: https://github.com/OpenAssetIO/OpenAssetIO/issues/1127
-#
-from ._openassetio import trait
-
-TraitsData = trait.TraitsData
-del trait
-
-
-from ._openassetio import errors as _errors
-
-BatchElementError = _errors.BatchElementError
-
-
-class BatchElementException(_errors.BatchElementException):
-    """
-    @deprecated See openassetio.errors.BatchElementException
-    """
-
-    def __init__(self, index, error):
-        super().__init__(index, error, error.message)
-
-
-UnknownBatchElementException = _errors.BatchElementException
-InvalidEntityReferenceBatchElementException = _errors.BatchElementException
-MalformedEntityReferenceBatchElementException = _errors.BatchElementException
-EntityAccessErrorBatchElementException = _errors.BatchElementException
-EntityResolutionErrorBatchElementException = _errors.BatchElementException
-InvalidPreflightHintBatchElementException = _errors.BatchElementException
-InvalidTraitSetBatchElementException = _errors.BatchElementException
-
-del _errors
diff --git a/src/openassetio-python/package/openassetio/exceptions.py b/src/openassetio-python/package/openassetio/exceptions.py
deleted file mode 100644
index eb6201044..000000000
--- a/src/openassetio-python/package/openassetio/exceptions.py
+++ /dev/null
@@ -1,189 +0,0 @@
-#
-#   Copyright 2013-2023 The Foundry Visionmongers Ltd
-#
-#   Licensed under the Apache License, Version 2.0 (the "License");
-#   you may not use this file except in compliance with the License.
-#   You may obtain a copy of the License at
-#
-#       http://www.apache.org/licenses/LICENSE-2.0
-#
-#   Unless required by applicable law or agreed to in writing, software
-#   distributed under the License is distributed on an "AS IS" BASIS,
-#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-#   See the License for the specific language governing permissions and
-#   limitations under the License.
-#
-"""
-@namespace openassetio.exceptions
-Defines exceptions used in the OpenAssetIO codebase.
-
-@deprecated See @ref fqref{openassetio.errors}
-"""
-import warnings
-
-
-from openassetio import errors as _errors
-
-OpenAssetIOException = _errors.OpenAssetIOException
-
-del _errors
-
-warnings.warn("The exceptions module has moved to openassetio.errors", DeprecationWarning)
-
-
-class UserCanceled(OpenAssetIOException):
-    """
-    Thrown by the progress mechanism to interrupt execution whenever the
-    user cancels an action (perhaps using an on-screen button).
-
-    @unstable
-    """
-
-    def __str__(self):
-        return "Operation Canceled"
-
-
-##
-# @name Manager related Exceptions
-#
-## @{
-
-
-class ManagerException(OpenAssetIOException):
-    """
-    A base class for exceptions relating to, or raised by a manager.
-
-    @unstable
-    """
-
-
-class StateError(ManagerException):
-    """
-    Thrown by managers in error situations relating to the
-    managerState object.
-
-    @unstable
-    """
-
-
-class RetryableError(ManagerException):
-    """
-    Thrown by managers in error situations that can be safely retried
-    with idempotent behavior.
-
-    @unstable
-    """
-
-
-## @}
-
-
-##
-# @name Entity related Exceptions
-#
-## @{
-
-
-class BaseEntityException(ManagerException):
-    """
-    A base Exception for any @ref entity related errors to ensure
-    consistent presentation and encapsulation of the associated @ref
-    entity_reference.
-
-    @unstable
-    """
-
-    def __init__(self, message, entityReference=None):
-        """
-        @param message str, The message of the exception.
-
-        @param entityReference @fqref{EntityReference} "EntityReference"
-        The entity reference associated with the error. This should be
-        provided wherever known, and will be printed along with the
-        message in any traceback/etc... As such, there is no need to
-        embedded the entity reference in the message when using this
-        exception type.
-        """
-        super(BaseEntityException, self).__init__(message)
-        self.ref = entityReference
-
-    def __str__(self):
-        string = OpenAssetIOException.__str__(self)
-        return "%s (%s)" % (string, self.ref)
-
-
-class InvalidEntityReference(BaseEntityException):
-    """
-    Thrown whenever an Entity-based action is performed on an
-    unrecognized @ref entity_reference.
-
-    @unstable
-    """
-
-    def __init__(self, message="Invalid Entity Reference", entityReference=None):
-        super(InvalidEntityReference, self).__init__(message, entityReference)
-
-
-class MalformedEntityReference(BaseEntityException):
-    """
-    Thrown whenever an Entity-based action is performed on a
-    malformed @ref entity_reference.
-
-    @unstable
-    """
-
-    def __init__(self, message="Malformed Entity Reference", entityReference=None):
-        super(MalformedEntityReference, self).__init__(message, entityReference)
-
-
-class EntityResolutionError(BaseEntityException):
-    """
-    Thrown during @ref entity resolution,  if the Entity is valid, but
-    has no meaningful data to be resolved, or it can't be retrieved for
-    some other reason. It is also used during version finalisation and
-    any other entity-based operations on a valid @ref entity_reference
-    that fail for some reason.
-
-    @unstable
-    """
-
-    def __init__(self, message="Error resolving entity", entityReference=None):
-        super(EntityResolutionError, self).__init__(message, entityReference)
-
-
-class BaseEntityInteractionError(BaseEntityException):
-    """
-    A base class for errors relating to entity-centric actions.
-
-    @unstable
-    """
-
-
-class PreflightError(BaseEntityInteractionError):
-    """
-    Thrown to represent some error during pre-flight that isn't due to
-    any specific of the @ref entity_reference itself.
-
-    @unstable
-    """
-
-
-class RegistrationError(BaseEntityInteractionError):
-    """
-    Thrown to represent some error during registration that isn't due to
-    any specific of the @ref entity_reference itself.
-
-    @unstable
-    """
-
-
-## @}
-
-
-class PluginError(OpenAssetIOException):
-    """
-    Thrown by the plugin system in relation to errors encountered
-    during the loading/initialization of plugins.
-
-    @unstable
-    """


Test patch:
diff --git a/src/openassetio-core/tests/CMakeLists.txt b/src/openassetio-core/tests/CMakeLists.txt
index c69a54cd6..325279bd7 100644
--- a/src/openassetio-core/tests/CMakeLists.txt
+++ b/src/openassetio-core/tests/CMakeLists.txt
@@ -24,7 +24,6 @@ target_sources(openassetio-core-cpp-test-exe
     BatchElementErrorTest.cpp
     ContextTest.cpp
     TraitsDataTest.cpp
-    deprecationsTest.cpp
     versionTest.cpp
     hostApi/ManagerTest.cpp
     managerApi/HostTest.cpp
diff --git a/src/openassetio-core/tests/deprecationsTest.cpp b/src/openassetio-core/tests/deprecationsTest.cpp
deleted file mode 100644
index 17f1f9f5d..000000000
--- a/src/openassetio-core/tests/deprecationsTest.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-// SPDX-License-Identifier: Apache-2.0
-// Copyright 2023 The Foundry Visionmongers Ltd
-#include <type_traits>
-
-#include <catch2/catch.hpp>
-
-// Disable deprecation warning that triggers -Werror, failing the build.
-#if defined(__clang__)
-#pragma clang diagnostic ignored "-Wdeprecated-declarations"
-#elif defined(__GNUC__)
-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-#endif
-
-#include <openassetio/TraitsData.hpp>
-#include <openassetio/trait/TraitsData.hpp>
-
-#include <openassetio/BatchElementError.hpp>
-#include <openassetio/errors/BatchElementError.hpp>
-
-// Tests for deprecated functionality.
-// All cases must have links to the relevant GitHub issues.
-
-// https://github.com/OpenAssetIO/OpenAssetIO/issues/1127
-SCENARIO("TraitsData still accessible in top level namespace") {
-  STATIC_REQUIRE(std::is_same_v<openassetio::TraitsData, openassetio::trait::TraitsData>);
-}
-
-// https://github.com/OpenAssetIO/OpenAssetIO/issues/1071
-// https://github.com/OpenAssetIO/OpenAssetIO/issues/1073
-SCENARIO("BatchElementError and exceptions still accessible in top level namespace") {
-  STATIC_REQUIRE(
-      std::is_same_v<openassetio::BatchElementError, openassetio::errors::BatchElementError>);
-}
-SCENARIO("BatchElementExceptions still accessible in top level namespace") {
-  const openassetio::BatchElementError anError{
-      openassetio::BatchElementError::ErrorCode::kEntityAccessError, "msg"};
-  const openassetio::BatchElementException anException{0, anError};
-  CHECK(anException.what() == std::string{"msg"});
-
-  STATIC_REQUIRE(std::is_base_of_v<openassetio::errors::BatchElementException,
-                                   openassetio::BatchElementException>);
-  STATIC_REQUIRE(std::is_base_of_v<openassetio::BatchElementException,
-                                   openassetio::UnknownBatchElementException>);
-  STATIC_REQUIRE(std::is_base_of_v<openassetio::BatchElementException,
-                                   openassetio::InvalidEntityReferenceBatchElementException>);
-  STATIC_REQUIRE(std::is_base_of_v<openassetio::BatchElementException,
-                                   openassetio::MalformedEntityReferenceBatchElementException>);
-  STATIC_REQUIRE(std::is_base_of_v<openassetio::BatchElementException,
-                                   openassetio::EntityAccessErrorBatchElementException>);
-  STATIC_REQUIRE(std::is_base_of_v<openassetio::BatchElementException,
-                                   openassetio::EntityResolutionErrorBatchElementException>);
-  STATIC_REQUIRE(std::is_base_of_v<openassetio::BatchElementException,
-                                   openassetio::InvalidPreflightHintBatchElementException>);
-  STATIC_REQUIRE(std::is_base_of_v<openassetio::BatchElementException,
-                                   openassetio::InvalidTraitSetBatchElementException>);
-}
diff --git a/src/openassetio-python/tests/package/test_deprecations.py b/src/openassetio-python/tests/package/test_deprecations.py
deleted file mode 100644
index c78471864..000000000
--- a/src/openassetio-python/tests/package/test_deprecations.py
+++ /dev/null
@@ -1,104 +0,0 @@
-#
-#   Copyright 2023 The Foundry Visionmongers Ltd
-#
-#   Licensed under the Apache License, Version 2.0 (the "License");
-#   you may not use this file except in compliance with the License.
-#   You may obtain a copy of the License at
-#
-#       http://www.apache.org/licenses/LICENSE-2.0
-#
-#   Unless required by applicable law or agreed to in writing, software
-#   distributed under the License is distributed on an "AS IS" BASIS,
-#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-#   See the License for the specific language governing permissions and
-#   limitations under the License.
-#
-"""
-Tests for deprecated functionality.
-
-All cases must have a link to the relevant GitHub issue in their
-docstrings.
-"""
-
-# pylint: disable=invalid-name
-# pylint: disable=missing-function-docstring,import-outside-toplevel
-
-
-import pytest
-
-
-def test_renamed_kField_constants():
-    """
-    https://github.com/OpenAssetIO/OpenAssetIO/issues/998
-    """
-    from openassetio import constants
-
-    assert constants.kField_SmallIcon == constants.kInfoKey_SmallIcon
-    assert constants.kField_Icon == constants.kInfoKey_Icon
-    assert (
-        constants.kField_EntityReferencesMatchPrefix
-        == constants.kInfoKey_EntityReferencesMatchPrefix
-    )
-
-
-def test_top_level_TraitsData_import():
-    """
-    https://github.com/OpenAssetIO/OpenAssetIO/issues/1127
-    """
-    from openassetio import trait, TraitsData
-
-    assert TraitsData is trait.TraitsData
-
-
-def test_top_level_exceptions_import():
-    """
-    https://github.com/OpenAssetIO/OpenAssetIO/issues/1071
-    https://github.com/OpenAssetIO/OpenAssetIO/issues/1073
-    """
-    from openassetio import (
-        BatchElementError,
-        BatchElementException,
-        UnknownBatchElementException,
-        InvalidEntityReferenceBatchElementException,
-        MalformedEntityReferenceBatchElementException,
-        EntityAccessErrorBatchElementException,
-        EntityResolutionErrorBatchElementException,
-        InvalidPreflightHintBatchElementException,
-        InvalidTraitSetBatchElementException,
-        errors,
-    )
-
-    assert BatchElementError is errors.BatchElementError
-
-    assert issubclass(BatchElementException, errors.BatchElementException)
-    expected_message = "a message"
-    an_error = BatchElementError(BatchElementError.ErrorCode.kEntityAccessError, expected_message)
-    an_exception = BatchElementException(0, an_error)
-    assert str(an_exception) == expected_message
-
-    assert UnknownBatchElementException is errors.BatchElementException
-    assert InvalidEntityReferenceBatchElementException is errors.BatchElementException
-    assert MalformedEntityReferenceBatchElementException is errors.BatchElementException
-    assert EntityAccessErrorBatchElementException is errors.BatchElementException
-    assert EntityResolutionErrorBatchElementException is errors.BatchElementException
-    assert InvalidPreflightHintBatchElementException is errors.BatchElementException
-    assert InvalidTraitSetBatchElementException is errors.BatchElementException
-
-    with pytest.warns(
-        DeprecationWarning, match="The exceptions module has moved to openassetio.errors"
-    ):
-        from openassetio import exceptions
-
-    assert exceptions.OpenAssetIOException is errors.OpenAssetIOException
-    assert exceptions.UserCanceled
-    assert exceptions.ManagerException
-    assert exceptions.StateError
-    assert exceptions.RetryableError
-    assert exceptions.BaseEntityException
-    assert exceptions.InvalidEntityReference
-    assert exceptions.MalformedEntityReference
-    assert exceptions.EntityResolutionError
-    assert exceptions.BaseEntityInteractionError
-    assert exceptions.PreflightError
-    assert exceptions.RegistrationError
-    assert exceptions.PluginError