apache-airflow-mypy 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,10 @@
1
+ # Build artifacts
2
+ dist/
3
+ build/
4
+ *.egg-info/
5
+
6
+ # Python cache
7
+ __pycache__/
8
+ *.py[cod]
9
+ *$py.class
10
+ *.iml
@@ -0,0 +1,44 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+ ---
18
+ default_stages: [pre-commit, pre-push]
19
+ minimum_prek_version: '0.2.0'
20
+ default_language_version:
21
+ python: python3
22
+ node: 22.19.0
23
+ golang: 1.24.0
24
+ repos:
25
+ - repo: local
26
+ hooks:
27
+ - id: mypy-airflow-mypy
28
+ stages: ['pre-push']
29
+ name: Run mypy for airflow-mypy plugins
30
+ language: python
31
+ entry: ../../scripts/ci/prek/mypy.py
32
+ files:
33
+ (?x)
34
+ ^src/airflow_mypy/.*\.py$|
35
+ ^tests/.*\.py$
36
+ require_serial: true
37
+ - id: mypy-airflow-mypy-manual
38
+ stages: ['manual']
39
+ name: Run mypy for airflow-mypy (manual)
40
+ language: python
41
+ entry: ../../scripts/ci/prek/mypy_folder.py dev/mypy
42
+ pass_filenames: false
43
+ files: ^.*\.py$
44
+ require_serial: true
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,5 @@
1
+ Apache Airflow
2
+ Copyright 2016-2026 The Apache Software Foundation
3
+
4
+ This product includes software developed at
5
+ The Apache Software Foundation (http://www.apache.org/).
@@ -0,0 +1,102 @@
1
+ Metadata-Version: 2.4
2
+ Name: apache-airflow-mypy
3
+ Version: 0.1.0
4
+ Summary: Apache Airflow Mypy plugins
5
+ Project-URL: Bug Tracker, https://github.com/apache/airflow/issues
6
+ Project-URL: Documentation, https://airflow.apache.org/docs/apache-airflow-mypy/stable/index.html
7
+ Project-URL: Downloads, https://archive.apache.org/dist/airflow/airflow-mypy/
8
+ Project-URL: Homepage, https://airflow.apache.org/
9
+ Project-URL: Release Notes, https://airflow.apache.org/docs/apache-airflow-mypy/stable/changelog.html
10
+ Project-URL: Slack Chat, https://s.apache.org/airflow-slack
11
+ Project-URL: Source Code, https://github.com/apache/airflow
12
+ Project-URL: LinkedIn, https://www.linkedin.com/company/apache-airflow/
13
+ Project-URL: Mastodon, https://fosstodon.org/@airflow
14
+ Project-URL: Bluesky, https://bsky.app/profile/apache-airflow.bsky.social
15
+ Project-URL: YouTube, https://www.youtube.com/channel/UCSXwxpWZQ7XZ1WL3wqevChA/
16
+ Author-email: Apache Software Foundation <dev@airflow.apache.org>
17
+ Maintainer-email: Apache Software Foundation <dev@airflow.apache.org>
18
+ License-Expression: Apache-2.0
19
+ License-File: LICENSE
20
+ License-File: NOTICE
21
+ Keywords: airflow,automation,dag,data,orchestration,pipelines,workflow
22
+ Classifier: Development Status :: 5 - Production/Stable
23
+ Classifier: Environment :: Console
24
+ Classifier: Environment :: Web Environment
25
+ Classifier: Framework :: Apache Airflow
26
+ Classifier: Intended Audience :: Developers
27
+ Classifier: Intended Audience :: System Administrators
28
+ Classifier: Programming Language :: Python :: 3.10
29
+ Classifier: Programming Language :: Python :: 3.11
30
+ Classifier: Programming Language :: Python :: 3.12
31
+ Classifier: Programming Language :: Python :: 3.13
32
+ Classifier: Topic :: System :: Monitoring
33
+ Requires-Python: !=3.15,>=3.10
34
+ Requires-Dist: mypy>=1.0.0
35
+ Description-Content-Type: text/markdown
36
+
37
+ <!--
38
+ Licensed to the Apache Software Foundation (ASF) under one
39
+ or more contributor license agreements. See the NOTICE file
40
+ distributed with this work for additional information
41
+ regarding copyright ownership. The ASF licenses this file
42
+ to you under the Apache License, Version 2.0 (the
43
+ "License"); you may not use this file except in compliance
44
+ with the License. You may obtain a copy of the License at
45
+
46
+ http://www.apache.org/licenses/LICENSE-2.0
47
+
48
+ Unless required by applicable law or agreed to in writing,
49
+ software distributed under the License is distributed on an
50
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
51
+ KIND, either express or implied. See the License for the
52
+ specific language governing permissions and limitations
53
+ under the License.
54
+ -->
55
+
56
+ <!-- START doctoc generated TOC please keep comment here to allow auto update -->
57
+ <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
58
+
59
+ - [Apache Airflow Mypy Plugins](#apache-airflow-mypy-plugins)
60
+ - [Installation](#installation)
61
+ - [Usage](#usage)
62
+ - [Available Plugins](#available-plugins)
63
+
64
+ <!-- END doctoc generated TOC please keep comment here to allow auto update -->
65
+
66
+ # Apache Airflow Mypy Plugins
67
+
68
+ This package provides Mypy plugins for Apache Airflow to enhance type checking capabilities.
69
+
70
+ ## Installation
71
+
72
+ ```bash
73
+ pip install apache-airflow-mypy
74
+ ```
75
+
76
+ ## Usage
77
+
78
+ Add the plugins to your `mypy.ini` or `pyproject.toml` configuration:
79
+
80
+ ### Using mypy.ini
81
+
82
+ ```ini
83
+ [mypy]
84
+ plugins = airflow_mypy.plugins.decorators, airflow_mypy.plugins.outputs
85
+ ```
86
+
87
+ ### Using pyproject.toml
88
+
89
+ ```toml
90
+ [tool.mypy]
91
+ plugins = ["airflow_mypy.plugins.decorators", "airflow_mypy.plugins.outputs"]
92
+ ```
93
+
94
+ ## Available Plugins
95
+
96
+ ### decorators Plugin
97
+
98
+ Provides type checking support for Airflow decorators that modify function signatures.
99
+
100
+ ### outputs Plugin
101
+
102
+ Handles type checking for operator outputs and XComArg types, allowing proper type inference when passing task outputs between tasks.
@@ -0,0 +1,66 @@
1
+ <!--
2
+ Licensed to the Apache Software Foundation (ASF) under one
3
+ or more contributor license agreements. See the NOTICE file
4
+ distributed with this work for additional information
5
+ regarding copyright ownership. The ASF licenses this file
6
+ to you under the Apache License, Version 2.0 (the
7
+ "License"); you may not use this file except in compliance
8
+ with the License. You may obtain a copy of the License at
9
+
10
+ http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+ Unless required by applicable law or agreed to in writing,
13
+ software distributed under the License is distributed on an
14
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ KIND, either express or implied. See the License for the
16
+ specific language governing permissions and limitations
17
+ under the License.
18
+ -->
19
+
20
+ <!-- START doctoc generated TOC please keep comment here to allow auto update -->
21
+ <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
22
+
23
+ - [Apache Airflow Mypy Plugins](#apache-airflow-mypy-plugins)
24
+ - [Installation](#installation)
25
+ - [Usage](#usage)
26
+ - [Available Plugins](#available-plugins)
27
+
28
+ <!-- END doctoc generated TOC please keep comment here to allow auto update -->
29
+
30
+ # Apache Airflow Mypy Plugins
31
+
32
+ This package provides Mypy plugins for Apache Airflow to enhance type checking capabilities.
33
+
34
+ ## Installation
35
+
36
+ ```bash
37
+ pip install apache-airflow-mypy
38
+ ```
39
+
40
+ ## Usage
41
+
42
+ Add the plugins to your `mypy.ini` or `pyproject.toml` configuration:
43
+
44
+ ### Using mypy.ini
45
+
46
+ ```ini
47
+ [mypy]
48
+ plugins = airflow_mypy.plugins.decorators, airflow_mypy.plugins.outputs
49
+ ```
50
+
51
+ ### Using pyproject.toml
52
+
53
+ ```toml
54
+ [tool.mypy]
55
+ plugins = ["airflow_mypy.plugins.decorators", "airflow_mypy.plugins.outputs"]
56
+ ```
57
+
58
+ ## Available Plugins
59
+
60
+ ### decorators Plugin
61
+
62
+ Provides type checking support for Airflow decorators that modify function signatures.
63
+
64
+ ### outputs Plugin
65
+
66
+ Handles type checking for operator outputs and XComArg types, allowing proper type inference when passing task outputs between tasks.
@@ -0,0 +1,32 @@
1
+ .. Licensed to the Apache Software Foundation (ASF) under one
2
+ or more contributor license agreements. See the NOTICE file
3
+ distributed with this work for additional information
4
+ regarding copyright ownership. The ASF licenses this file
5
+ to you under the Apache License, Version 2.0 (the
6
+ "License"); you may not use this file except in compliance
7
+ with the License. You may obtain a copy of the License at
8
+
9
+ .. http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ .. Unless required by applicable law or agreed to in writing,
12
+ software distributed under the License is distributed on an
13
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ KIND, either express or implied. See the License for the
15
+ specific language governing permissions and limitations
16
+ under the License.
17
+
18
+ apache-airflow-mypy 0.1.0
19
+ -------------------------------
20
+
21
+ Initial release of apache-airflow-mypy, a package providing Mypy plugins for Apache Airflow.
22
+
23
+ Features
24
+ ^^^^^^^^
25
+
26
+ - Mypy plugin for typed decorators that modify function signatures
27
+ - Mypy plugin for operator outputs and XComArg type handling
28
+ - Support for type checking Airflow decorators with injected parameters
29
+ - Proper type inference when passing task outputs between tasks
30
+
31
+ This package makes the Airflow Mypy plugins installable and reusable for users who want to
32
+ enhance type checking in their Airflow DAGs.
@@ -0,0 +1,50 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+ [tool.towncrier]
18
+ name = "Apache Airflow Mypy"
19
+ filename = "RELEASE_NOTES.rst"
20
+ underlines = ["-", '^']
21
+
22
+ [[tool.towncrier.type]]
23
+ directory = "significant"
24
+ name = "Significant Changes"
25
+ showcontent = true
26
+
27
+ [[tool.towncrier.type]]
28
+ directory = "feature"
29
+ name = "Features"
30
+ showcontent = true
31
+
32
+ [[tool.towncrier.type]]
33
+ directory = "improvement"
34
+ name = "Improvements"
35
+ showcontent = true
36
+
37
+ [[tool.towncrier.type]]
38
+ directory = "bugfix"
39
+ name = "Bug Fixes"
40
+ showcontent = true
41
+
42
+ [[tool.towncrier.type]]
43
+ directory = "doc"
44
+ name = "Doc only Changes"
45
+ showcontent = true
46
+
47
+ [[tool.towncrier.type]]
48
+ directory = "misc"
49
+ name = "Misc"
50
+ showcontent = true
@@ -0,0 +1,122 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+ [project]
18
+ name = "apache-airflow-mypy"
19
+ dynamic = ["version"]
20
+ description = "Apache Airflow Mypy plugins"
21
+ readme = { file = "README.md", content-type = "text/markdown" }
22
+ license = "Apache-2.0"
23
+ license-files = ["LICENSE", "NOTICE"]
24
+ requires-python = ">=3.10,!=3.15"
25
+
26
+ authors = [
27
+ {name="Apache Software Foundation", email="dev@airflow.apache.org"},
28
+ ]
29
+ maintainers = [
30
+ {name="Apache Software Foundation", email="dev@airflow.apache.org"},
31
+ ]
32
+ keywords = [ "airflow", "orchestration", "workflow", "dag", "pipelines", "automation", "data" ]
33
+ classifiers = [
34
+ "Development Status :: 5 - Production/Stable",
35
+ "Environment :: Console",
36
+ "Environment :: Web Environment",
37
+ "Intended Audience :: Developers",
38
+ "Intended Audience :: System Administrators",
39
+ "Framework :: Apache Airflow",
40
+ "Programming Language :: Python :: 3.10",
41
+ "Programming Language :: Python :: 3.11",
42
+ "Programming Language :: Python :: 3.12",
43
+ "Programming Language :: Python :: 3.13",
44
+ "Topic :: System :: Monitoring",
45
+ ]
46
+ dependencies = [
47
+ "mypy>=1.0.0"
48
+ ]
49
+
50
+ [project.urls]
51
+ "Bug Tracker" = "https://github.com/apache/airflow/issues"
52
+ Documentation = "https://airflow.apache.org/docs/apache-airflow-mypy/stable/index.html"
53
+ Downloads = "https://archive.apache.org/dist/airflow/airflow-mypy/"
54
+ Homepage = "https://airflow.apache.org/"
55
+ "Release Notes" = "https://airflow.apache.org/docs/apache-airflow-mypy/stable/changelog.html"
56
+ "Slack Chat" = "https://s.apache.org/airflow-slack"
57
+ "Source Code" = "https://github.com/apache/airflow"
58
+ LinkedIn = "https://www.linkedin.com/company/apache-airflow/"
59
+ Mastodon = "https://fosstodon.org/@airflow"
60
+ Bluesky = "https://bsky.app/profile/apache-airflow.bsky.social"
61
+ YouTube = "https://www.youtube.com/channel/UCSXwxpWZQ7XZ1WL3wqevChA/"
62
+
63
+ [build-system]
64
+ requires = ["hatchling==1.29.0"]
65
+ build-backend = "hatchling.build"
66
+
67
+ [tool.hatch.version]
68
+ path = "src/airflow_mypy/__init__.py"
69
+
70
+ [tool.hatch.build.targets.wheel]
71
+ packages = ["src/airflow_mypy"]
72
+
73
+ [tool.ruff]
74
+ extend = "../../pyproject.toml"
75
+ src = ["src"]
76
+ namespace-packages = ["src/airflow_mypy"]
77
+
78
+ [tool.ruff.lint.extend-per-file-ignores]
79
+ "tests/*" = ["S101", "TRY002"]
80
+
81
+ [tool.pytest.ini_options]
82
+ testpaths = ["tests"]
83
+ pythonpath = ["src"]
84
+
85
+ [tool.towncrier]
86
+ name = "Apache Airflow Mypy"
87
+ filename = "RELEASE_NOTES.rst"
88
+ directory = "newsfragments"
89
+ underlines = ["-", "^"]
90
+
91
+ [[tool.towncrier.type]]
92
+ directory = "significant"
93
+ name = "Significant Changes"
94
+ showcontent = true
95
+
96
+ [[tool.towncrier.type]]
97
+ directory = "feature"
98
+ name = "Features"
99
+ showcontent = true
100
+
101
+ [[tool.towncrier.type]]
102
+ directory = "improvement"
103
+ name = "Improvements"
104
+ showcontent = true
105
+
106
+ [[tool.towncrier.type]]
107
+ directory = "bugfix"
108
+ name = "Bug Fixes"
109
+ showcontent = true
110
+
111
+ [[tool.towncrier.type]]
112
+ directory = "doc"
113
+ name = "Doc only Changes"
114
+ showcontent = true
115
+
116
+ [[tool.towncrier.type]]
117
+ directory = "misc"
118
+ name = "Misc"
119
+ showcontent = true
120
+
121
+ [tool.uv]
122
+ required-version = ">=0.6.3"
@@ -0,0 +1,22 @@
1
+ #
2
+ # Licensed to the Apache Software Foundation (ASF) under one
3
+ # or more contributor license agreements. See the NOTICE file
4
+ # distributed with this work for additional information
5
+ # regarding copyright ownership. The ASF licenses this file
6
+ # to you under the Apache License, Version 2.0 (the
7
+ # "License"); you may not use this file except in compliance
8
+ # with the License. You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing,
13
+ # software distributed under the License is distributed on an
14
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ # KIND, either express or implied. See the License for the
16
+ # specific language governing permissions and limitations
17
+ # under the License.
18
+ from __future__ import annotations
19
+
20
+ __path__ = __import__("pkgutil").extend_path(__path__, __name__)
21
+
22
+ __version__ = "0.1.0"
@@ -0,0 +1,17 @@
1
+ #
2
+ # Licensed to the Apache Software Foundation (ASF) under one
3
+ # or more contributor license agreements. See the NOTICE file
4
+ # distributed with this work for additional information
5
+ # regarding copyright ownership. The ASF licenses this file
6
+ # to you under the Apache License, Version 2.0 (the
7
+ # "License"); you may not use this file except in compliance
8
+ # with the License. You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing,
13
+ # software distributed under the License is distributed on an
14
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ # KIND, either express or implied. See the License for the
16
+ # specific language governing permissions and limitations
17
+ # under the License.
@@ -0,0 +1,83 @@
1
+ #
2
+ # Licensed to the Apache Software Foundation (ASF) under one
3
+ # or more contributor license agreements. See the NOTICE file
4
+ # distributed with this work for additional information
5
+ # regarding copyright ownership. The ASF licenses this file
6
+ # to you under the Apache License, Version 2.0 (the
7
+ # "License"); you may not use this file except in compliance
8
+ # with the License. You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing,
13
+ # software distributed under the License is distributed on an
14
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ # KIND, either express or implied. See the License for the
16
+ # specific language governing permissions and limitations
17
+ # under the License.
18
+ from __future__ import annotations
19
+
20
+ import copy
21
+ import functools
22
+
23
+ from mypy.nodes import ARG_NAMED_OPT
24
+ from mypy.plugin import FunctionContext, Plugin
25
+ from mypy.types import CallableType, NoneType, UnionType
26
+
27
+ TYPED_DECORATORS = {
28
+ "airflow.providers.google.cloud.hooks.dataflow._fallback_to_project_id_from_variables": ["project_id"],
29
+ "fallback_to_default_project_id of GoogleBaseHook": ["project_id"],
30
+ "provide_gcp_credential_file of GoogleBaseHook": [],
31
+ }
32
+
33
+
34
+ class TypedDecoratorPlugin(Plugin):
35
+ """Mypy plugin for typed decorators."""
36
+
37
+ def get_function_hook(self, fullname: str):
38
+ """Check for known typed decorators by name."""
39
+ if fullname in TYPED_DECORATORS:
40
+ return functools.partial(
41
+ _analyze_decorator,
42
+ provided_arguments=TYPED_DECORATORS[fullname],
43
+ )
44
+ return None
45
+
46
+
47
+ def _analyze_decorator(function_ctx: FunctionContext, provided_arguments: list[str]):
48
+ if not isinstance(function_ctx.arg_types[0][0], CallableType):
49
+ return function_ctx.default_return_type
50
+ if not isinstance(function_ctx.default_return_type, CallableType):
51
+ return function_ctx.default_return_type
52
+ return _change_decorator_function_type(
53
+ function_ctx.arg_types[0][0],
54
+ function_ctx.default_return_type,
55
+ provided_arguments,
56
+ )
57
+
58
+
59
+ def _change_decorator_function_type(
60
+ decorated: CallableType,
61
+ decorator: CallableType,
62
+ provided_arguments: list[str],
63
+ ) -> CallableType:
64
+ decorator.arg_kinds = decorated.arg_kinds
65
+ decorator.arg_names = decorated.arg_names
66
+
67
+ # Mark provided arguments as optional
68
+ decorator.arg_types = copy.copy(decorated.arg_types)
69
+ for argument in provided_arguments:
70
+ try:
71
+ index = decorated.arg_names.index(argument)
72
+ except ValueError:
73
+ continue
74
+ decorated_type = decorated.arg_types[index]
75
+ decorator.arg_types[index] = UnionType.make_union([decorated_type, NoneType()])
76
+ decorated.arg_kinds[index] = ARG_NAMED_OPT
77
+
78
+ return decorator
79
+
80
+
81
+ def plugin(version: str):
82
+ """Mypy plugin entrypoint."""
83
+ return TypedDecoratorPlugin
@@ -0,0 +1,79 @@
1
+ #
2
+ # Licensed to the Apache Software Foundation (ASF) under one
3
+ # or more contributor license agreements. See the NOTICE file
4
+ # distributed with this work for additional information
5
+ # regarding copyright ownership. The ASF licenses this file
6
+ # to you under the Apache License, Version 2.0 (the
7
+ # "License"); you may not use this file except in compliance
8
+ # with the License. You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing,
13
+ # software distributed under the License is distributed on an
14
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ # KIND, either express or implied. See the License for the
16
+ # specific language governing permissions and limitations
17
+ # under the License.
18
+ from __future__ import annotations
19
+
20
+ from collections.abc import Callable
21
+
22
+ from mypy.plugin import AttributeContext, MethodContext, Plugin
23
+ from mypy.types import AnyType, Type, TypeOfAny
24
+
25
+ OUTPUT_PROPERTIES = {
26
+ "airflow.models.baseoperator.BaseOperator.output",
27
+ "airflow.models.mappedoperator.MappedOperator.output",
28
+ "airflow.sdk.bases.operator.BaseOperator.output",
29
+ "airflow.sdk.definitions.mappedoperator.MappedOperator.output",
30
+ }
31
+
32
+ TASK_CALL_FUNCTIONS = {
33
+ "airflow.decorators.base.Task.__call__",
34
+ "airflow.sdk.bases.decorator.Task.__call__",
35
+ }
36
+
37
+
38
+ class OperatorOutputPlugin(Plugin):
39
+ """Plugin to convert XComArg to the runtime type.
40
+
41
+ This allows us to pass an *XComArg* to a downstream task, such as::
42
+
43
+ @task
44
+ def f(a: str) -> int:
45
+ return len(a)
46
+
47
+
48
+ f(op.output) # "op" is an operator instance.
49
+ f(g()) # "g" is a taskflow task.
50
+
51
+ where the *a* argument of ``f`` should accept a *str* at runtime, but can be
52
+ provided with an *XComArg* in the DAG.
53
+
54
+ In the long run, it is probably a good idea to make *XComArg* a generic that
55
+ carries information about the task's return type, and build the entire XCom
56
+ mechanism into the type checker. But Python's type system is still limiting
57
+ in this regard now, and (using the above example) we yet to have a good way
58
+ to convert ``f``'s argument list from ``[str]`` to ``[XComArg[str] | str]``.
59
+ Perhaps *ParamSpec* will be extended enough one day to accommodate this.
60
+ """
61
+
62
+ @staticmethod
63
+ def _treat_as_any(context: AttributeContext | MethodContext) -> Type:
64
+ """Pretend *XComArg* is actually *typing.Any*."""
65
+ return AnyType(TypeOfAny.special_form, line=context.context.line, column=context.context.column)
66
+
67
+ def get_attribute_hook(self, fullname: str) -> Callable[[AttributeContext], Type] | None:
68
+ if fullname not in OUTPUT_PROPERTIES:
69
+ return None
70
+ return self._treat_as_any
71
+
72
+ def get_method_hook(self, fullname: str) -> Callable[[MethodContext], Type] | None:
73
+ if fullname not in TASK_CALL_FUNCTIONS:
74
+ return None
75
+ return self._treat_as_any
76
+
77
+
78
+ def plugin(version: str):
79
+ return OperatorOutputPlugin
@@ -0,0 +1,52 @@
1
+ #
2
+ # Licensed to the Apache Software Foundation (ASF) under one
3
+ # or more contributor license agreements. See the NOTICE file
4
+ # distributed with this work for additional information
5
+ # regarding copyright ownership. The ASF licenses this file
6
+ # to you under the Apache License, Version 2.0 (the
7
+ # "License"); you may not use this file except in compliance
8
+ # with the License. You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing,
13
+ # software distributed under the License is distributed on an
14
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ # KIND, either express or implied. See the License for the
16
+ # specific language governing permissions and limitations
17
+ # under the License.
18
+ from __future__ import annotations
19
+
20
+
21
+ def test_decorators_plugin_import():
22
+ """Test that decorators plugin can be imported."""
23
+ from airflow_mypy.plugins import decorators
24
+
25
+ assert hasattr(decorators, "plugin")
26
+ assert callable(decorators.plugin)
27
+
28
+
29
+ def test_outputs_plugin_import():
30
+ """Test that outputs plugin can be imported."""
31
+ from airflow_mypy.plugins import outputs
32
+
33
+ assert hasattr(outputs, "plugin")
34
+ assert callable(outputs.plugin)
35
+
36
+
37
+ def test_decorators_plugin_entrypoint():
38
+ """Test that decorators plugin entry point works."""
39
+ from airflow_mypy.plugins.decorators import plugin
40
+
41
+ # The plugin function should return a plugin class when called with a version string
42
+ plugin_class = plugin("1.0")
43
+ assert plugin_class is not None
44
+
45
+
46
+ def test_outputs_plugin_entrypoint():
47
+ """Test that outputs plugin entry point works."""
48
+ from airflow_mypy.plugins.outputs import plugin
49
+
50
+ # The plugin function should return a plugin class when called with a version string
51
+ plugin_class = plugin("1.0")
52
+ assert plugin_class is not None