Skip to content

Commit

Permalink
Apply clang-tidy to thrift/lib/py3
Browse files Browse the repository at this point in the history
Summary:
- [modernize-concat-nested-namespaces](https://clang.llvm.org/extra/clang-tidy/checks/modernize/concat-nested-namespaces.html)
- [modernize-use-override](https://clang.llvm.org/extra/clang-tidy/checks/modernize/use-override.html) (only 1 change)
- [modernize-use-using](https://clang.llvm.org/extra/clang-tidy/checks/modernize/use-using.html) (only 1 change)

Reviewed By: createdbysk

Differential Revision: D67655278

fbshipit-source-id: 191a06d9b11f2bea07c088e681274c251b9125f7
  • Loading branch information
yoney authored and facebook-github-bot committed Dec 26, 2024
1 parent efd42b0 commit 2acc434
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 58 deletions.
6 changes: 2 additions & 4 deletions thrift/lib/py3/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
#include <thrift/lib/cpp2/async/RocketClientChannel.h>
#include <thrift/lib/py3/client_wrapper.h>

namespace thrift {
namespace py3 {
namespace thrift::py3 {
using RequestChannel_ptr = apache::thrift::RequestChannel::Ptr;

/*
Expand All @@ -51,5 +50,4 @@ inline void destroyInEventBaseThread(RequestChannel_ptr&& ptr) {
eb->runInEventBaseThread([ptr = std::move(ptr)] {});
}

} // namespace py3
} // namespace thrift
} // namespace thrift::py3
6 changes: 2 additions & 4 deletions thrift/lib/py3/client_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
#include <thrift/lib/cpp2/async/AsyncClient.h>
#include <thrift/lib/cpp2/async/RequestChannel.h>

namespace thrift {
namespace py3 {
namespace thrift::py3 {

class ClientWrapper {
protected:
Expand Down Expand Up @@ -57,5 +56,4 @@ class ClientWrapper {
}
};

} // namespace py3
} // namespace thrift
} // namespace thrift::py3
8 changes: 2 additions & 6 deletions thrift/lib/py3/exceptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@

#include <folly/ExceptionWrapper.h>

namespace thrift {
namespace py3 {
namespace exception {
namespace thrift::py3::exception {

// The only place this function is used it needs a shared_ptr, so may as
// well just return one instead of a unique_ptr
Expand All @@ -34,6 +32,4 @@ std::shared_ptr<T> try_make_shared_exception(
return e ? std::make_shared<T>(*e) : std::shared_ptr<T>();
}

} // namespace exception
} // namespace py3
} // namespace thrift
} // namespace thrift::py3::exception
6 changes: 2 additions & 4 deletions thrift/lib/py3/serializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
#include <thrift/lib/cpp2/protocol/Protocol.h>
#include <thrift/lib/cpp2/protocol/Serializer.h>

namespace thrift {
namespace py3 {
namespace thrift::py3 {
using apache::thrift::protocol::PROTOCOL_TYPES;
template <typename T>
std::unique_ptr<folly::IOBuf> serialize(const T* obj, PROTOCOL_TYPES protocol) {
Expand Down Expand Up @@ -71,5 +70,4 @@ size_t deserialize(const folly::IOBuf* buf, T* obj, PROTOCOL_TYPES protocol) {
LOG(FATAL) << "Bad serialization protocol " << uint8_t(protocol);
}
}
} // namespace py3
} // namespace thrift
} // namespace thrift::py3
8 changes: 3 additions & 5 deletions thrift/lib/py3/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
#include <thrift/lib/cpp/server/TServerEventHandler.h>
#include <thrift/lib/cpp2/server/RequestsRegistry.h>

namespace thrift {
namespace py3 {
namespace thrift::py3 {
using AddressHandler = folly::Function<void(folly::SocketAddress)>;

template <class Ret, class... Args>
Expand All @@ -45,7 +44,7 @@ class Py3ServerEventHandler
folly::Executor* executor, AddressHandler address_handler)
: executor_(executor), address_handler_(std::move(address_handler)) {}

void preServe(const folly::SocketAddress* address) {
void preServe(const folly::SocketAddress* address) override {
executor_->add([addr = *address, this]() mutable {
address_handler_(std::move(addr));
});
Expand All @@ -66,5 +65,4 @@ inline std::string getRequestId() {
return {};
}

} // namespace py3
} // namespace thrift
} // namespace thrift::py3
7 changes: 3 additions & 4 deletions thrift/lib/py3/stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
#if __has_include(<thrift/lib/py3/stream_api.h>) && FOLLY_HAS_COROUTINES
#include <thrift/lib/py3/stream_api.h> // @manual

namespace thrift {
namespace py3 {
namespace thrift::py3 {

namespace {

Expand All @@ -41,6 +40,6 @@ void cancelPythonIterator(PyObject* iter) {
cancelAsyncGenerator(iter);
}

} // namespace py3
} // namespace thrift
} // namespace thrift::py3

#endif
6 changes: 2 additions & 4 deletions thrift/lib/py3/stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@

#if FOLLY_HAS_COROUTINES

namespace thrift {
namespace py3 {
namespace thrift::py3 {

template <typename T>
class ClientBufferedStreamWrapper {
Expand Down Expand Up @@ -122,8 +121,7 @@ apache::thrift::ServerStream<StreamElement> createAsyncIteratorFromPyIterator(
}
});
}
} // namespace py3
} // namespace thrift
} // namespace thrift::py3

#else /* !FOLLY_HAS_COROUTINES */
#error Thrift stream type support needs C++ coroutines, which are not currently available. \
Expand Down
8 changes: 3 additions & 5 deletions thrift/lib/py3/test/BinaryTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,12 @@ class Buffer : boost::totally_ordered<Buffer> {

} // namespace test

namespace apache {
namespace thrift {
namespace apache::thrift {

template <>
class Cpp2Ops<test::Buffer> {
public:
typedef test::Buffer Type;
using Type = test::Buffer;
static constexpr protocol::TType thriftType() { return protocol::T_STRING; }
template <class Protocol>
static uint32_t write(Protocol* prot, const Type* value) {
Expand All @@ -95,5 +94,4 @@ class Cpp2Ops<test::Buffer> {
}
};

} // namespace thrift
} // namespace apache
} // namespace apache::thrift
8 changes: 2 additions & 6 deletions thrift/lib/py3/test/cpp_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
#include <thrift/lib/cpp2/server/ThriftServer.h>
#include <thrift/lib/py3/test/gen-cpp2/TestingService.tcc>

namespace thrift {
namespace py3 {
namespace test {
namespace thrift::py3::test {

class TestingService
: public apache::thrift::ServiceHandler<cpp2::TestingService> {
Expand All @@ -38,6 +36,4 @@ class TestingService
}
};

} // namespace test
} // namespace py3
} // namespace thrift
} // namespace thrift::py3::test
8 changes: 2 additions & 6 deletions thrift/lib/py3/test/interactions/interaction_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
#include <thrift/lib/py3/test/interactions/gen-cpp2/BlankService.h>
#include <thrift/lib/py3/test/interactions/gen-cpp2/Calculator.h>

namespace interactions {
namespace test {
namespace thrift {
namespace interactions::test::thrift {
struct SemiCalculatorHandler : apache::thrift::ServiceHandler<Calculator> {
struct SemiAdditionHandler
: apache::thrift::ServiceHandler<Calculator>::AdditionIf {
Expand Down Expand Up @@ -60,6 +58,4 @@ struct SemiCalculatorHandler : apache::thrift::ServiceHandler<Calculator> {
};
struct SemiBlankServiceHandler
: apache::thrift::ServiceHandler<BlankServiceRenamed> {};
} // namespace thrift
} // namespace test
} // namespace interactions
} // namespace interactions::test::thrift
8 changes: 2 additions & 6 deletions thrift/lib/py3/test/is_overload/func.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
#include <thrift/lib/cpp/transport/THeader.h>
#include <thrift/lib/cpp2/server/ThriftServer.h>

namespace thrift {
namespace py3 {
namespace test {
namespace thrift::py3::test {

bool isOverloaded(
const apache::thrift::transport::THeader::StringToStringMap& /* headers */,
Expand All @@ -38,6 +36,4 @@ bool checkOverload(
// otherwise, it will return no value
return ret.hasValue();
}
} // namespace test
} // namespace py3
} // namespace thrift
} // namespace thrift::py3::test
6 changes: 2 additions & 4 deletions thrift/lib/py3/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
#include <thrift/lib/cpp/Thrift.h>
#include <thrift/lib/cpp2/FieldRef.h>

namespace thrift {
namespace py3 {
namespace thrift::py3 {

template <typename T>
std::shared_ptr<T> constant_shared_ptr(const T& x) {
Expand Down Expand Up @@ -184,5 +183,4 @@ PyObject* init_unicode_from_cpp(const T& str) {
return PyUnicode_FromStringAndSize(str.data(), str.size());
}

} // namespace py3
} // namespace thrift
} // namespace thrift::py3

0 comments on commit 2acc434

Please sign in to comment.