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
124
124
*/
125
125
[[nodiscard]] auto contains (BuildNumber point) const -> bool;
126
126
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 ;
132
128
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 ;
137
130
138
131
private:
139
132
Original file line number Diff line number Diff line change 23
23
#include " mamba/specs/version_spec.hpp"
24
24
#include " mamba/util/flat_set.hpp"
25
25
#include " mamba/util/heap_optional.hpp"
26
- #include " mamba/util/tuple_hash.hpp"
27
26
28
27
namespace mamba ::specs
29
28
{
@@ -142,22 +141,15 @@ namespace mamba::specs
142
141
*/
143
142
[[nodiscard]] auto contains_except_channel (const PackageInfo& pkg) const -> bool;
144
143
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 ;
156
151
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 ;
161
153
162
154
auto extra_members_hash () const -> std::size_t;
163
155
Original file line number Diff line number Diff line change @@ -897,6 +897,8 @@ namespace mambapy
897
897
.def (" is_simple" , &MatchSpec::is_simple)
898
898
.def (" is_only_package_name" , &MatchSpec::is_only_package_name)
899
899
.def (" conda_build_form" , &MatchSpec::conda_build_form)
900
+ .def (py::self == py::self)
901
+ .def (py::self != py::self)
900
902
.def (" __str__" , &MatchSpec::to_string)
901
903
.def (" __copy__" , ©<MatchSpec>)
902
904
.def (" __deepcopy__" , &deepcopy<MatchSpec>, py::arg (" memo" ));
Original file line number Diff line number Diff line change @@ -932,6 +932,8 @@ def test_MatchSpec():
932
932
assert ms .is_file ()
933
933
assert str (ms .name ) == "pkg"
934
934
assert ms .filename == "pkg-2-bld.conda"
935
+ assert ms == ms
936
+ assert ms != MatchSpec .parse ("foo" )
935
937
936
938
# Errors
937
939
with pytest .raises (libmambapy .specs .ParseError ):
You can’t perform that action at this time.
0 commit comments