Skip to content
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

LF-54899 Add pre-commit hooks for linting and Bentley copyrights #109

Closed
Closed
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
25 changes: 10 additions & 15 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
name: pre-commit
name: Run pre-commit checks

on:
push:
branches:
- master

pull_request:
branches:
- master
workflow_dispatch:

jobs:
pre-commit:
runs-on: ubuntu-latest

steps:
- name: Checkout Repo
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Run pre-commit
uses: pre-commit/[email protected]
uses: seequent/leapfrog-actions-util/.github/workflows/run_pre_commit_checks.yml@run-pre-commit-checks-v1
with:
python_version: "3.10"
requirements_file_path: requirements_dev.txt
artifactory_user: ${{ vars.ARTIFACTORY_USER }}
secrets:
artifactory_token: ${{ secrets.LEAPFROG_ARTIFACTORY_TOKEN }}
github_pat: ${{ secrets.SVC_LEAPFROG_AUTOMATION_GITHUB_PAT }}
36 changes: 22 additions & 14 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-toml
- id: trailing-whitespace
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-toml
- id: check-yaml
- id: trailing-whitespace
- id: end-of-file-fixer

- repo: https://github.com/psf/black
rev: 24.8.0
hooks:
- id: black
language_version: python3.10
- repo: https://github.com/seequent/bentley-copyright-utils
rev: v1.2.1
hooks:
- id: bentley-root-copyright-check
- id: bentley-file-copyright-check

- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 24.8.0
hooks:
- id: black
language_version: python3.10

- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
5 changes: 5 additions & 0 deletions COPYRIGHT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# COPYRIGHT

All works in this repository are unpublished and proprietary property of Bentley Systems, Incorporated.

Copyright (c) 2017-2024 Bentley Systems, Incorporated. All rights reserved.
5 changes: 5 additions & 0 deletions pure_interface/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Bentley Systems, Incorporated. All rights reserved.
# See COPYRIGHT.md in the repository root for full copyright notice.
# --------------------------------------------------------------------------------------------

from ._sub_interface import sub_interface_of
from .adaption import AdapterTracker, adapt_args, adapts, register_adapter
from .delegation import Delegate
Expand Down
5 changes: 5 additions & 0 deletions pure_interface/_sub_interface.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Bentley Systems, Incorporated. All rights reserved.
# See COPYRIGHT.md in the repository root for full copyright notice.
# --------------------------------------------------------------------------------------------

""" decorator function for sub-interfaces

A sub-interface is a non-empty subset of another, larger, interface.
Expand Down
5 changes: 5 additions & 0 deletions pure_interface/adaption.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Bentley Systems, Incorporated. All rights reserved.
# See COPYRIGHT.md in the repository root for full copyright notice.
# --------------------------------------------------------------------------------------------

from __future__ import absolute_import, division, print_function

import functools
Expand Down
5 changes: 5 additions & 0 deletions pure_interface/delegation.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Bentley Systems, Incorporated. All rights reserved.
# See COPYRIGHT.md in the repository root for full copyright notice.
# --------------------------------------------------------------------------------------------

from __future__ import absolute_import, division, print_function

import operator
Expand Down
6 changes: 6 additions & 0 deletions pure_interface/errors.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Bentley Systems, Incorporated. All rights reserved.
# See COPYRIGHT.md in the repository root for full copyright notice.
# --------------------------------------------------------------------------------------------


class PureInterfaceError(Exception):
"""All exceptions raised by this module are subclasses of this exception"""

Expand Down
5 changes: 5 additions & 0 deletions pure_interface/interface.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Bentley Systems, Incorporated. All rights reserved.
# See COPYRIGHT.md in the repository root for full copyright notice.
# --------------------------------------------------------------------------------------------

"""
pure_interface enforces empty functions and properties on interfaces and provides adaption and structural type checking.
"""
Expand Down
5 changes: 5 additions & 0 deletions pure_interface/mypy_plugin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Bentley Systems, Incorporated. All rights reserved.
# See COPYRIGHT.md in the repository root for full copyright notice.
# --------------------------------------------------------------------------------------------

from collections.abc import Callable
from typing import Dict, Final, List, Optional, TypeAlias, cast

Expand Down
1 change: 1 addition & 0 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
-r requirements.txt
mypy
pre-commit==3.8.0
5 changes: 5 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Bentley Systems, Incorporated. All rights reserved.
# See COPYRIGHT.md in the repository root for full copyright notice.
# --------------------------------------------------------------------------------------------

import warnings

warnings.filterwarnings("ignore", category=UserWarning)
5 changes: 5 additions & 0 deletions tests/interface_module.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Bentley Systems, Incorporated. All rights reserved.
# See COPYRIGHT.md in the repository root for full copyright notice.
# --------------------------------------------------------------------------------------------

import pure_interface


Expand Down
5 changes: 5 additions & 0 deletions tests/mypy_source.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Bentley Systems, Incorporated. All rights reserved.
# See COPYRIGHT.md in the repository root for full copyright notice.
# --------------------------------------------------------------------------------------------

"""With the pure-interface mypy plugin enabled, mypy should validate this file without error.

This is working except for dataclasses __init__ call arguments.
Expand Down
5 changes: 5 additions & 0 deletions tests/temp.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Bentley Systems, Incorporated. All rights reserved.
# See COPYRIGHT.md in the repository root for full copyright notice.
# --------------------------------------------------------------------------------------------

import dataclasses

import pure_interface
Expand Down
5 changes: 5 additions & 0 deletions tests/test_adapt_args_anno.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Bentley Systems, Incorporated. All rights reserved.
# See COPYRIGHT.md in the repository root for full copyright notice.
# --------------------------------------------------------------------------------------------

import unittest

try:
Expand Down
5 changes: 5 additions & 0 deletions tests/test_adapt_args_no_anno.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Bentley Systems, Incorporated. All rights reserved.
# See COPYRIGHT.md in the repository root for full copyright notice.
# --------------------------------------------------------------------------------------------

import unittest

import pure_interface.errors
Expand Down
5 changes: 5 additions & 0 deletions tests/test_adaption.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Bentley Systems, Incorporated. All rights reserved.
# See COPYRIGHT.md in the repository root for full copyright notice.
# --------------------------------------------------------------------------------------------

import unittest
import warnings
from unittest import mock
Expand Down
5 changes: 5 additions & 0 deletions tests/test_dataclass_support.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Bentley Systems, Incorporated. All rights reserved.
# See COPYRIGHT.md in the repository root for full copyright notice.
# --------------------------------------------------------------------------------------------

import unittest
from dataclasses import dataclass

Expand Down
5 changes: 5 additions & 0 deletions tests/test_delegate.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Bentley Systems, Incorporated. All rights reserved.
# See COPYRIGHT.md in the repository root for full copyright notice.
# --------------------------------------------------------------------------------------------

import dataclasses
import unittest
from unittest import mock
Expand Down
5 changes: 5 additions & 0 deletions tests/test_func_sigs3.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Bentley Systems, Incorporated. All rights reserved.
# See COPYRIGHT.md in the repository root for full copyright notice.
# --------------------------------------------------------------------------------------------

import types
import unittest

Expand Down
5 changes: 5 additions & 0 deletions tests/test_func_sigs_po.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Bentley Systems, Incorporated. All rights reserved.
# See COPYRIGHT.md in the repository root for full copyright notice.
# --------------------------------------------------------------------------------------------

# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals

Expand Down
5 changes: 5 additions & 0 deletions tests/test_function_sigs.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Bentley Systems, Incorporated. All rights reserved.
# See COPYRIGHT.md in the repository root for full copyright notice.
# --------------------------------------------------------------------------------------------

import types
import unittest

Expand Down
5 changes: 5 additions & 0 deletions tests/test_generic_support.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Bentley Systems, Incorporated. All rights reserved.
# See COPYRIGHT.md in the repository root for full copyright notice.
# --------------------------------------------------------------------------------------------

import unittest
from typing import Iterable, List, TypeVar

Expand Down
5 changes: 5 additions & 0 deletions tests/test_implementation_checks.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Bentley Systems, Incorporated. All rights reserved.
# See COPYRIGHT.md in the repository root for full copyright notice.
# --------------------------------------------------------------------------------------------

import abc
import unittest
import warnings
Expand Down
5 changes: 5 additions & 0 deletions tests/test_inheritance.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Bentley Systems, Incorporated. All rights reserved.
# See COPYRIGHT.md in the repository root for full copyright notice.
# --------------------------------------------------------------------------------------------

import unittest

import pure_interface
Expand Down
5 changes: 5 additions & 0 deletions tests/test_isinstance.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Bentley Systems, Incorporated. All rights reserved.
# See COPYRIGHT.md in the repository root for full copyright notice.
# --------------------------------------------------------------------------------------------

import io
import unittest
import warnings
Expand Down
5 changes: 5 additions & 0 deletions tests/test_meta_classes.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Bentley Systems, Incorporated. All rights reserved.
# See COPYRIGHT.md in the repository root for full copyright notice.
# --------------------------------------------------------------------------------------------

import abc
import unittest

Expand Down
5 changes: 5 additions & 0 deletions tests/test_module_funcs.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Bentley Systems, Incorporated. All rights reserved.
# See COPYRIGHT.md in the repository root for full copyright notice.
# --------------------------------------------------------------------------------------------

import unittest

from pure_interface import *
Expand Down
5 changes: 5 additions & 0 deletions tests/test_no_content_checks.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Bentley Systems, Incorporated. All rights reserved.
# See COPYRIGHT.md in the repository root for full copyright notice.
# --------------------------------------------------------------------------------------------

import abc
import unittest

Expand Down
5 changes: 5 additions & 0 deletions tests/test_singledispatch.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Bentley Systems, Incorporated. All rights reserved.
# See COPYRIGHT.md in the repository root for full copyright notice.
# --------------------------------------------------------------------------------------------

import unittest
from functools import singledispatchmethod
from typing import Any
Expand Down
5 changes: 5 additions & 0 deletions tests/test_sub_interfaces.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Bentley Systems, Incorporated. All rights reserved.
# See COPYRIGHT.md in the repository root for full copyright notice.
# --------------------------------------------------------------------------------------------

import dataclasses
import unittest

Expand Down
5 changes: 5 additions & 0 deletions tests/test_tracker.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Bentley Systems, Incorporated. All rights reserved.
# See COPYRIGHT.md in the repository root for full copyright notice.
# --------------------------------------------------------------------------------------------

import unittest

from pure_interface import *
Expand Down