# Copyright (c) 2022, 2025, Oracle and/or its affiliates.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License, version 2.0, as
# published by the Free Software Foundation.
#
# This program is designed to work with certain software (including
# but not limited to OpenSSL) that is licensed under separate terms,
# as designated in a particular file or component or in included license
# documentation. The authors of MySQL hereby grant you an
# additional permission to link the program and your derivative works
# with the separately licensed software that they have either included with
# the program or referenced in the documentation.
#
# Without limiting anything contained in the foregoing, this file,
# which is part of MySQL Connector/Python, is also subject to the
# Universal FOSS Exception, version 1.0, a copy of which can be found at
# http://oss.oracle.com/licenses/universal-foss-exception.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License, version 2.0, for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA

[build-system]
requires = ['setuptools', 'wheel']
build-backend = 'setuptools.build_meta'

[tool.isort]
profile = 'black'
combine_as_imports = true
known_first_party = ['mysql.connector', 'mysqlx']
line_length = 88
lines_between_types = 1
skip_glob = [
    'mysql-connector-python/build/*',
    'mysqlx-connector-python/build/*',
    'mysql-connector-python/dist/*',
    'mysqlx-connector-python/dist/*',
    'mysql-connector-python/docs/*',
    'mysqlx-connector-python/docs/*',
    'mysql-connector-python/lib/mysql/connector/locales/eng',
    'mysqlx-connector-python/lib/mysqlx/locales/eng',
    'mysqlx-connector-python/lib/mysqlx/protobuf',
    'mysqlx-connector-python/lib/mysqlx/tls_ciphers.py',
    'mysql-connector-python/lib/mysql/tls_ciphers.py',
    'venv/*',
]

[tool.black]
line-length = 88
target-version = ['py310']
exclude = '''
(
  /(
    \.eggs
  | \.git
  | build
  | dist
  | docs
  | mysql-connector-python/lib/mysql/connector/locales/eng
  | mysql-connector-python/lib/mysql/opentelemetry
  | mysqlx-connector-python/lib/mysqlx/locales/eng
  | venv
  )/
  | mysql-connector-python/lib/mysql/connector/opentelemetry/instrumentation.py
  | mysqlx-connector-python/lib/mysqlx/protobuf/mysqlx_connection_pb2.py
  | mysqlx-connector-python/lib/mysqlx/protobuf/mysqlx_crud_pb2.py
  | mysqlx-connector-python/lib/mysqlx/protobuf/mysqlx_cursor_pb2.py
  | mysqlx-connector-python/lib/mysqlx/protobuf/mysqlx_datatypes_pb2.py
  | mysqlx-connector-python/lib/mysqlx/protobuf/mysqlx_expect_pb2.py
  | mysqlx-connector-python/lib/mysqlx/protobuf/mysqlx_expr_pb2.py
  | mysqlx-connector-python/lib/mysqlx/protobuf/mysqlx_notice_pb2.py
  | mysqlx-connector-python/lib/mysqlx/protobuf/mysqlx_pb2.py
  | mysqlx-connector-python/lib/mysqlx/protobuf/mysqlx_prepare_pb2.py
  | mysqlx-connector-python/lib/mysqlx/protobuf/mysqlx_resultset_pb2.py
  | mysqlx-connector-python/lib/mysqlx/protobuf/mysqlx_session_pb2.py
  | mysqlx-connector-python/lib/mysqlx/protobuf/mysqlx_sql_pb2.py
)
'''

[tool.coverage.run]
branch = true
omit = [
    '*/dist-packages/*',
    '*/site-packages/*',
    'mysql-connector-python/cpydist/*',
    'mysqlx-connector-python/cpydist/*',
    'mysql-connector-python/examples/*',
    'setupinfo.py',
    'mysql-connector-python/tests/*',
    'mysqlx-connector-python/tests/*',
    'mysql-connector-python/unittests.py',
    'mysqlx-connector-python/unittests.py',
    'mysql-connector-python/lib/mysql/opentelemetry/*',
]

[tool.coverage.html]
directory = 'build/coverage_html'

[tool.coverage.xml]
output = 'build/coverage.xml'

[tool.pylint.master]
load-plugins = ['pylint.extensions.overlapping_exceptions']
ignore-paths = ['mysqlx-connector-python/lib/mysqlx/protobuf/mysqlx_*', 'mysql-connector-python/lib/mysql/opentelemetry']
init-hook = 'import sys; sys.path.append("mysql-connector-python/lib"); sys.path.append("mysqlx-connector-python/lib")'

[tool.pylint.messages_control]
disable = [
    'duplicate-code',
    'import-outside-toplevel',
    'too-few-public-methods',
    'too-many-ancestors',
    'too-many-arguments',
    'too-many-branches',
    'too-many-instance-attributes',
    'too-many-lines',
    'too-many-locals',
    'too-many-nested-blocks',
    'too-many-public-methods',
    'too-many-return-statements',
    'too-many-statements',
    'wrong-import-order',
    'wrong-import-position',
    'too-many-positional-arguments',
    'protected-access',
]

[tool.pylint.format]
good-names = ["i", "f", "db", "dt", "ca", "hi", "pw", "X"]

[tool.mypy]
# https://mypy.readthedocs.io/en/stable/command_line.html
# https://mypy.readthedocs.io/en/stable/config_file.html#using-a-pyproject-toml-file
python_version = "3.10"
disallow_untyped_defs = true
show_error_codes = true
warn_unused_ignores = true
allow_redefinition = true
no_strict_optional = true
no_implicit_optional = true
files = [
    'mysql-connector-python/lib/mysql',
    'mysqlx-connector-python/lib/mysqlx',
]
exclude = [
  'mysqlx-connector-python/lib/mysqlx/protobuf/mysqlx_connection_pb2.py',
  'mysqlx-connector-python/lib/mysqlx/protobuf/mysqlx_crud_pb2.py',
  'mysqlx-connector-python/lib/mysqlx/protobuf/mysqlx_cursor_pb2.py',
  'mysqlx-connector-python/lib/mysqlx/protobuf/mysqlx_datatypes_pb2.py',
  'mysqlx-connector-python/lib/mysqlx/protobuf/mysqlx_expect_pb2.py',
  'mysqlx-connector-python/lib/mysqlx/protobuf/mysqlx_expr_pb2.py',
  'mysqlx-connector-python/lib/mysqlx/protobuf/mysqlx_notice_pb2.py',
  'mysqlx-connector-python/lib/mysqlx/protobuf/mysqlx_pb2.py',
  'mysqlx-connector-python/lib/mysqlx/protobuf/mysqlx_prepare_pb2.py',
  'mysqlx-connector-python/lib/mysqlx/protobuf/mysqlx_resultset_pb2.py',
  'mysqlx-connector-python/lib/mysqlx/protobuf/mysqlx_session_pb2.py',
  'mysqlx-connector-python/lib/mysqlx/protobuf/mysqlx_sql_pb2.py',
  'mysql-connector-python/lib/mysql/opentelemetry',
]

[[tool.mypy.overrides]]
module = [
  '_mysql_connector',
  '_mysqlxpb',
  'cryptography.*',
  'dns.*',
  'google.*',
  'lz4.*',
  'mysql.*',
  'mysqlx.protobuf',
  'oci',
  'sqlparse',
  'sspi',
  'sspicon',
  'opentelemetry',
  'opentelemetry.*',
  'fido2.*',
  'lib.mysql.connector.aio.connection_cext',
]
ignore_missing_imports = true

[[tool.mypy.overrides]]
module = [
  'lib.mysql.opentelemetry',
  'lib.mysql.opentelemetry.*',
]
ignore_errors = true

[tool.pylint.typecheck]
ignored-modules = [
  'numpy*',
  'pandas*',
  'sklearn*',
  'pydantic*',
  'langchain*',
]
