Skip to content

Replace cpplint with clang-format #55150

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Oct 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 7 additions & 13 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,6 @@ repos:
- id: fix-encoding-pragma
args: [--remove]
- id: trailing-whitespace
- repo: https://github.com/cpplint/cpplint
rev: 1.6.1
hooks:
- id: cpplint
exclude: ^pandas/_libs/include/pandas/vendored/klib
args: [
--quiet,
'--extensions=c,h',
'--headers=h',
--recursive,
--linelength=88,
'--filter=-readability/casting,-runtime/int,-build/include_subdir,-readability/fn_size'
]
- repo: https://github.com/pylint-dev/pylint
rev: v3.0.0b0
hooks:
Expand Down Expand Up @@ -127,6 +114,13 @@ repos:
rev: v0.6.8
hooks:
- id: sphinx-lint
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: ea59a72
hooks:
- id: clang-format
files: ^pandas/_libs/src|^pandas/_libs/include
args: [-i]
types_or: [c, c++]
- repo: local
hooks:
- id: pyright
Expand Down
2 changes: 1 addition & 1 deletion doc/source/development/contributing_codebase.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Pre-commit

Additionally, :ref:`Continuous Integration <contributing.ci>` will run code formatting checks
like ``black``, ``ruff``,
``isort``, and ``cpplint`` and more using `pre-commit hooks <https://pre-commit.com/>`_.
``isort``, and ``clang-format`` and more using `pre-commit hooks <https://pre-commit.com/>`_.
Any warnings from these checks will cause the :ref:`Continuous Integration <contributing.ci>` to fail; therefore,
it is helpful to run the check yourself before submitting code. This
can be done by installing ``pre-commit`` (which should already have happened if you followed the instructions
Expand Down
6 changes: 2 additions & 4 deletions pandas/_libs/include/pandas/datetime/date_conversions.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ int scaleNanosecToUnit(npy_int64 *value, NPY_DATETIMEUNIT unit);
// up to precision `base` e.g. base="s" yields 2020-01-03T00:00:00Z
// while base="ns" yields "2020-01-01T00:00:00.000000000Z"
// len is mutated to save the length of the returned string
char *int64ToIso(int64_t value,
NPY_DATETIMEUNIT valueUnit,
NPY_DATETIMEUNIT base,
size_t *len);
char *int64ToIso(int64_t value, NPY_DATETIMEUNIT valueUnit,
NPY_DATETIMEUNIT base, size_t *len);

// TODO(username): this function doesn't do a lot; should augment or
// replace with scaleNanosecToUnit
Expand Down
6 changes: 3 additions & 3 deletions pandas/_libs/include/pandas/datetime/pd_datetime.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ See NUMPY_LICENSE.txt for the license.

#ifndef NPY_NO_DEPRECATED_API
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
#endif // NPY_NO_DEPRECATED_API
#endif // NPY_NO_DEPRECATED_API

#include <numpy/ndarraytypes.h>
#include "pandas/datetime/date_conversions.h"
#include "pandas/vendored/numpy/datetime/np_datetime.h"
#include "pandas/vendored/numpy/datetime/np_datetime_strings.h"
#include "pandas/datetime/date_conversions.h"
#include <numpy/ndarraytypes.h>

#ifdef __cplusplus
extern "C" {
Expand Down
24 changes: 12 additions & 12 deletions pandas/_libs/include/pandas/inline_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ The full license is in the LICENSE file, distributed with this software.
#pragma once

#ifndef PANDAS_INLINE
#if defined(__clang__)
#define PANDAS_INLINE static __inline__ __attribute__ ((__unused__))
#elif defined(__GNUC__)
#define PANDAS_INLINE static __inline__
#elif defined(_MSC_VER)
#define PANDAS_INLINE static __inline
#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
#define PANDAS_INLINE static inline
#else
#define PANDAS_INLINE
#endif // __GNUC__
#endif // PANDAS_INLINE
#if defined(__clang__)
#define PANDAS_INLINE static __inline__ __attribute__((__unused__))
#elif defined(__GNUC__)
#define PANDAS_INLINE static __inline__
#elif defined(_MSC_VER)
#define PANDAS_INLINE static __inline
#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
#define PANDAS_INLINE static inline
#else
#define PANDAS_INLINE
#endif // __GNUC__
#endif // PANDAS_INLINE
8 changes: 4 additions & 4 deletions pandas/_libs/include/pandas/parser/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ The full license is in the LICENSE file, distributed with this software.
#pragma once

#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include "tokenizer.h"
#include <Python.h>

#define FS(source) ((file_source *)source)

typedef struct _rd_source {
PyObject *obj;
PyObject *buffer;
size_t position;
PyObject *obj;
PyObject *buffer;
size_t position;
} rd_source;

#define RDS(source) ((rd_source *)source)
Expand Down
11 changes: 5 additions & 6 deletions pandas/_libs/include/pandas/parser/pd_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ extern "C" {
#endif

#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include "pandas/parser/tokenizer.h"
#include <Python.h>

typedef struct {
int (*to_double)(char *, double *, char, char, int *);
Expand Down Expand Up @@ -81,11 +81,10 @@ static PandasParser_CAPI *PandasParserAPI = NULL;
PandasParserAPI->parser_set_default_options((self))
#define parser_consume_rows(self, nrows) \
PandasParserAPI->parser_consume_rows((self), (nrows))
#define parser_trim_buffers(self) \
PandasParserAPI->parser_trim_buffers((self))
#define tokenize_all_rows(self, encoding_errors) \
#define parser_trim_buffers(self) PandasParserAPI->parser_trim_buffers((self))
#define tokenize_all_rows(self, encoding_errors) \
PandasParserAPI->tokenize_all_rows((self), (encoding_errors))
#define tokenize_nrows(self, nrows, encoding_errors) \
#define tokenize_nrows(self, nrows, encoding_errors) \
PandasParserAPI->tokenize_nrows((self), (nrows), (encoding_errors))
#define str_to_int64(p_item, int_min, int_max, error, t_sep) \
PandasParserAPI->str_to_int64((p_item), (int_min), (int_max), (error), \
Expand All @@ -104,7 +103,7 @@ static PandasParser_CAPI *PandasParserAPI = NULL;
PandasParserAPI->round_trip((p), (q), (decimal), (sci), (tsep), \
(skip_trailing), (error), (maybe_int))
#define to_boolean(item, val) PandasParserAPI->to_boolean((item), (val))
#endif /* !defined(_PANDAS_PARSER_IMPL) */
#endif /* !defined(_PANDAS_PARSER_IMPL) */

#ifdef __cplusplus
}
Expand Down
Loading