Skip to content

Commit

Permalink
fix: add explicit ordering to includes
Browse files Browse the repository at this point in the history
  • Loading branch information
henryiii committed Feb 3, 2022
1 parent d3746a9 commit 9057962
Show file tree
Hide file tree
Showing 48 changed files with 105 additions and 53 deletions.
16 changes: 16 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,27 @@ BinPackParameters: false
BreakBeforeBinaryOperators: All
BreakConstructorInitializers: BeforeColon
ColumnLimit: 99
IncludeBlocks: Regroup
IndentCaseLabels: true
IndentPPDirectives: AfterHash
IndentWidth: 4
Language: Cpp
SpaceAfterCStyleCast: true
Standard: Cpp11
TabWidth: 4
IncludeCategories:
- Regex: '<pybind11/.*'
Priority: -1
- Regex: 'pybind11.h"$'
Priority: 1
- Regex: '^".*/?detail/'
Priority: 1
SortPriority: 2
- Regex: '^"'
Priority: 1
SortPriority: 3
- Regex: '<[[:alnum:]._]+>'
Priority: 4
- Regex: '.*'
Priority: 5
...
1 change: 1 addition & 0 deletions include/pybind11/cast.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "detail/type_caster_base.h"
#include "detail/typeid.h"
#include "pytypes.h"

#include <array>
#include <cstring>
#include <functional>
Expand Down
3 changes: 1 addition & 2 deletions include/pybind11/chrono.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
#include <chrono>
#include <cmath>
#include <ctime>
#include <mutex>

#include <datetime.h>
#include <mutex>

// Backport the PyDateTime_DELTA functions from Python3.3 if required
#ifndef PyDateTime_DELTA_GET_DAYS
Expand Down
1 change: 1 addition & 0 deletions include/pybind11/complex.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#pragma once

#include "pybind11.h"

#include <complex>

/// glibc defines I as a macro which breaks things, e.g., boost template names
Expand Down
1 change: 1 addition & 0 deletions include/pybind11/detail/internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#pragma once

#include "../pytypes.h"

#include <exception>

/// Tracks the `internals` and `type_info` ABI version independent of the main library version.
Expand Down
1 change: 1 addition & 0 deletions include/pybind11/detail/type_caster_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "descr.h"
#include "internals.h"
#include "typeid.h"

#include <cstdint>
#include <iterator>
#include <new>
Expand Down
2 changes: 1 addition & 1 deletion include/pybind11/embed.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

#pragma once

#include "eval.h"
#include "pybind11.h"
#include "eval.h"

#include <memory>
#include <vector>
Expand Down
4 changes: 2 additions & 2 deletions include/pybind11/eval.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@

#pragma once

#include <utility>

#include "pybind11.h"

#include <utility>

PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
PYBIND11_NAMESPACE_BEGIN(detail)

Expand Down
1 change: 1 addition & 0 deletions include/pybind11/functional.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#pragma once

#include "pybind11.h"

#include <functional>

PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
Expand Down
3 changes: 2 additions & 1 deletion include/pybind11/numpy.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@

#pragma once

#include "complex.h"
#include "pybind11.h"
#include "complex.h"

#include <algorithm>
#include <array>
#include <cstdint>
Expand Down
5 changes: 2 additions & 3 deletions include/pybind11/pybind11.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,20 @@

#pragma once

#include "attr.h"
#include "detail/class.h"
#include "detail/init.h"
#include "attr.h"
#include "gil.h"
#include "options.h"

#include <cstdlib>
#include <cstring>
#include <memory>
#include <new>
#include <string>
#include <utility>
#include <vector>

#include <cstring>

#if defined(__cpp_lib_launder) && !(defined(_MSC_VER) && (_MSC_VER < 1914))
# define PYBIND11_STD_LAUNDER std::launder
# define PYBIND11_HAS_STD_LAUNDER 1
Expand Down
3 changes: 2 additions & 1 deletion include/pybind11/pytypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@

#pragma once

#include "buffer_info.h"
#include "detail/common.h"
#include "buffer_info.h"

#include <type_traits>
#include <utility>

Expand Down
3 changes: 2 additions & 1 deletion include/pybind11/stl.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@

#pragma once

#include "detail/common.h"
#include "pybind11.h"
#include "detail/common.h"

#include <deque>
#include <iostream>
#include <list>
Expand Down
5 changes: 2 additions & 3 deletions include/pybind11/stl/filesystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@

#pragma once

#include "../cast.h"
#include "../pybind11.h"
#include "../pytypes.h"

#include "../detail/common.h"
#include "../detail/descr.h"
#include "../cast.h"
#include "../pytypes.h"

#include <string>

Expand Down
1 change: 1 addition & 0 deletions tests/constructor_stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ inspection/testing in python) by using the functions with `print_` replaced with
*/

#include "pybind11_tests.h"

#include <list>
#include <sstream>
#include <typeindex>
Expand Down
3 changes: 2 additions & 1 deletion tests/cross_module_gil_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
All rights reserved. Use of this source code is governed by a
BSD-style license that can be found in the LICENSE file.
*/
#include <cstdint>
#include <pybind11/pybind11.h>

#include <cstdint>

// This file mimics a DSO that makes pybind11 calls but does not define a
// PYBIND11_MODULE. The purpose is to test that such a DSO can create a
// py::gil_scoped_acquire when the running thread is in a GIL-released state.
Expand Down
4 changes: 2 additions & 2 deletions tests/local_bindings.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#pragma once
#include <utility>

#include "pybind11_tests.h"

#include <utility>

/// Simple class used to test py::local:
template <int>
class LocalBase {
Expand Down
1 change: 1 addition & 0 deletions tests/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# define __OBJECT_H

# include "constructor_stats.h"

# include <atomic>

/// Reference counted object base class
Expand Down
4 changes: 2 additions & 2 deletions tests/pybind11_cross_module_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
BSD-style license that can be found in the LICENSE file.
*/

#include <pybind11/stl_bind.h>

#include "local_bindings.h"
#include "pybind11_tests.h"
#include "test_exceptions.h"

#include <pybind11/stl_bind.h>

#include <numeric>
#include <utility>

Expand Down
1 change: 1 addition & 0 deletions tests/pybind11_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/

#include "pybind11_tests.h"

#include "constructor_stats.h"

#include <functional>
Expand Down
3 changes: 2 additions & 1 deletion tests/test_buffers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
BSD-style license that can be found in the LICENSE file.
*/

#include <pybind11/stl.h>

#include "constructor_stats.h"
#include "pybind11_tests.h"
#include <pybind11/stl.h>

TEST_SUBMODULE(buffers, m) {
// test_from_python / test_to_python:
Expand Down
3 changes: 2 additions & 1 deletion tests/test_builtin_casters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
BSD-style license that can be found in the LICENSE file.
*/

#include "pybind11_tests.h"
#include <pybind11/complex.h>

#include "pybind11_tests.h"

struct ConstRefCasted {
int tag;
};
Expand Down
4 changes: 3 additions & 1 deletion tests/test_callbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
BSD-style license that can be found in the LICENSE file.
*/

#include <pybind11/functional.h>

#include "constructor_stats.h"
#include "pybind11_tests.h"
#include <pybind11/functional.h>

#include <thread>

int dummy_function(int i) { return i + 1; }
Expand Down
4 changes: 3 additions & 1 deletion tests/test_chrono.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
BSD-style license that can be found in the LICENSE file.
*/

#include <pybind11/chrono.h>

#include "pybind11_tests.h"

#include <chrono>
#include <pybind11/chrono.h>

struct different_resolutions {
using time_point_h = std::chrono::time_point<std::chrono::system_clock, std::chrono::hours>;
Expand Down
3 changes: 2 additions & 1 deletion tests/test_class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
# include <aligned_new>
#endif

#include <pybind11/stl.h>

#include "constructor_stats.h"
#include "local_bindings.h"
#include "pybind11_tests.h"
#include <pybind11/stl.h>

#include <utility>

Expand Down
3 changes: 2 additions & 1 deletion tests/test_copy_move.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
BSD-style license that can be found in the LICENSE file.
*/

#include <pybind11/stl.h>

#include "constructor_stats.h"
#include "pybind11_tests.h"
#include <pybind11/stl.h>

template <typename derived>
struct empty {
Expand Down
5 changes: 3 additions & 2 deletions tests/test_eigen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
BSD-style license that can be found in the LICENSE file.
*/

#include "constructor_stats.h"
#include "pybind11_tests.h"
#include <pybind11/eigen.h>
#include <pybind11/stl.h>

#include "constructor_stats.h"
#include "pybind11_tests.h"

#if defined(_MSC_VER)
# if _MSC_VER < 1910 // VS 2015's MSVC
# pragma warning(disable : 4127) // C4127: conditional expression is constant
Expand Down
1 change: 0 additions & 1 deletion tests/test_embed/test_interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#endif

#include <catch.hpp>

#include <cstdlib>
#include <fstream>
#include <functional>
Expand Down
1 change: 1 addition & 0 deletions tests/test_eval.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <pybind11/eval.h>

#include "pybind11_tests.h"

#include <utility>

TEST_SUBMODULE(eval_, m) {
Expand Down
2 changes: 1 addition & 1 deletion tests/test_exceptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#include "test_exceptions.h"

#include "local_bindings.h"

#include "pybind11_tests.h"

#include <exception>
#include <stdexcept>
#include <utility>
Expand Down
1 change: 1 addition & 0 deletions tests/test_exceptions.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once
#include "pybind11_tests.h"

#include <stdexcept>

// shared exceptions for cross_module_tests
Expand Down
1 change: 1 addition & 0 deletions tests/test_factory_constructors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include "constructor_stats.h"
#include "pybind11_tests.h"

#include <cmath>
#include <new>
#include <utility>
Expand Down
3 changes: 2 additions & 1 deletion tests/test_gil_scoped.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
BSD-style license that can be found in the LICENSE file.
*/

#include "pybind11_tests.h"
#include <pybind11/functional.h>

#include "pybind11_tests.h"

class VirtClass {
public:
virtual ~VirtClass() = default;
Expand Down
4 changes: 3 additions & 1 deletion tests/test_iostream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
# pragma warning(disable : 4702) // unreachable code in system header (xatomic.h(382))
#endif

#include <pybind11/iostream.h>

#include "pybind11_tests.h"

#include <atomic>
#include <iostream>
#include <mutex>
#include <pybind11/iostream.h>
#include <string>
#include <thread>

Expand Down
Loading

0 comments on commit 9057962

Please sign in to comment.