diff --git a/.mypy.ini b/.mypy.ini new file mode 100644 index 0000000..6abab15 --- /dev/null +++ b/.mypy.ini @@ -0,0 +1,2 @@ +# https://mypy.readthedocs.io/en/stable/config_file.html +[mypy] diff --git a/BUILD b/BUILD index 0d5cce9..c25a0c6 100644 --- a/BUILD +++ b/BUILD @@ -19,4 +19,11 @@ licenses(["notice"]) # MIT exports_files([ "LICENSE", "version.bzl", + ".mypy.ini", ]) + +label_flag( + name = "mypy_config", + build_setting_default = "//:.mypy.ini", + visibility = ["//visibility:public"], +) diff --git a/README.md b/README.md index 78c080f..42ba40f 100644 --- a/README.md +++ b/README.md @@ -124,16 +124,14 @@ mypy_test( ### Configuration To support the [MyPy configuration file](https://mypy.readthedocs.io/en/latest/config_file.html) you can add the -following to your `WORKSPACE`: +following to your `.bazelrc`: +```text +build --@mypy_integration//:mypy_config=//:mypy.ini ``` -load("@mypy_integration//:config.bzl", "mypy_configuration") - -mypy_configuration("//tools/typing:mypy.ini") -``` - -where `//tools/typing:mypy.ini` is a [valid MyPy config file](https://mypy.readthedocs.io/en/latest/config_file.html#config-file-format). +where `//:mypy.ini` is a [valid MyPy config file](https://mypy.readthedocs.io/en/latest/config_file.html#config-file-format) +within your projects workspace. ## 🛠 Development diff --git a/WORKSPACE b/WORKSPACE index 9bff0a4..656f778 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -8,10 +8,6 @@ load( mypy_integration_repositories() -load("//:config.bzl", "mypy_configuration") - -mypy_configuration() - load("//repositories:deps.bzl", mypy_integration_deps = "deps") mypy_integration_deps("//:current_mypy_version.txt") diff --git a/config.bzl b/config.bzl index 21b7895..f6d24f3 100644 --- a/config.bzl +++ b/config.bzl @@ -32,6 +32,11 @@ create_config = repository_rule( ) def mypy_configuration(mypy_config_file = None): + """**Deprecated**: Instead, see https://github.com/bazel-contrib/bazel-mypy-integration/blob/main/README.md#configuration + + Args: + mypy_config_file (Label, optional): The label of a mypy configuration file + """ create_config( name = "mypy_integration_config", config_filepath = mypy_config_file, diff --git a/mypy.bzl b/mypy.bzl index e4f3af9..5517e99 100644 --- a/mypy.bzl +++ b/mypy.bzl @@ -29,7 +29,7 @@ DEFAULT_ATTRS = { cfg = "host", ), "_mypy_config": attr.label( - default = Label("@mypy_integration_config//:mypy.ini"), + default = Label("//:mypy_config"), allow_single_file = True, ), }