File tree Expand file tree Collapse file tree 4 files changed +14
-25
lines changed
libmamba/include/mamba/specs Expand file tree Collapse file tree 4 files changed +14
-25
lines changed Original file line number Diff line number Diff line change @@ -124,16 +124,9 @@ namespace mamba::specs
124124 */
125125 [[nodiscard]] auto contains (BuildNumber point) const -> bool;
126126
127- // TODO(C++20): replace by the `= default` implementation of `operator==`
128- [[nodiscard]] auto operator ==(const BuildNumberSpec& other) const -> bool
129- {
130- return m_predicate == other.m_predicate ;
131- }
127+ [[nodiscard]] auto operator ==(const BuildNumberSpec& other) const -> bool = default ;
132128
133- [[nodiscard]] auto operator !=(const BuildNumberSpec& other) const -> bool
134- {
135- return !(*this == other);
136- }
129+ [[nodiscard]] auto operator !=(const BuildNumberSpec& other) const -> bool = default ;
137130
138131 private:
139132
Original file line number Diff line number Diff line change 2323#include " mamba/specs/version_spec.hpp"
2424#include " mamba/util/flat_set.hpp"
2525#include " mamba/util/heap_optional.hpp"
26- #include " mamba/util/tuple_hash.hpp"
2726
2827namespace mamba ::specs
2928{
@@ -142,22 +141,15 @@ namespace mamba::specs
142141 */
143142 [[nodiscard]] auto contains_except_channel (const PackageInfo& pkg) const -> bool;
144143
145- // TODO(C++20): replace by the `= default` implementation of `operator==`
146- [[nodiscard]] auto operator ==(const MatchSpec& other) const -> bool
147- {
148- return m_channel == other.m_channel //
149- && m_version == other.m_version //
150- && m_name == other.m_name //
151- && m_build_string == other.m_build_string //
152- && m_name_space == other.m_name_space //
153- && m_build_number == other.m_build_number //
154- && m_extra == other.m_extra ;
155- }
144+ /* *
145+ * Naive attribute-wise comparison.
146+ *
147+ * @warning Some complex matchspec could compare to false but actually represent the same
148+ * set of packages. This strong equality is hard to detect.
149+ */
150+ [[nodiscard]] auto operator ==(const MatchSpec& other) const -> bool = default ;
156151
157- [[nodiscard]] auto operator !=(const MatchSpec& other) const -> bool
158- {
159- return !(*this == other);
160- }
152+ [[nodiscard]] auto operator !=(const MatchSpec& other) const -> bool = default ;
161153
162154 auto extra_members_hash () const -> std::size_t;
163155
Original file line number Diff line number Diff line change @@ -897,6 +897,8 @@ namespace mambapy
897897 .def (" is_simple" , &MatchSpec::is_simple)
898898 .def (" is_only_package_name" , &MatchSpec::is_only_package_name)
899899 .def (" conda_build_form" , &MatchSpec::conda_build_form)
900+ .def (py::self == py::self)
901+ .def (py::self != py::self)
900902 .def (" __str__" , &MatchSpec::to_string)
901903 .def (" __copy__" , ©<MatchSpec>)
902904 .def (" __deepcopy__" , &deepcopy<MatchSpec>, py::arg (" memo" ));
Original file line number Diff line number Diff line change @@ -932,6 +932,8 @@ def test_MatchSpec():
932932 assert ms .is_file ()
933933 assert str (ms .name ) == "pkg"
934934 assert ms .filename == "pkg-2-bld.conda"
935+ assert ms == ms
936+ assert ms != MatchSpec .parse ("foo" )
935937
936938 # Errors
937939 with pytest .raises (libmambapy .specs .ParseError ):
You can’t perform that action at this time.
0 commit comments