Skip to content

Commit e197932

Browse files
authored
Add typing. (#18)
1 parent 6f2a3d2 commit e197932

14 files changed

+157
-124
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

+9-12
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,21 @@
1-
---
1+
______________________________________________________________________
22

3-
name: Bug Report
4-
about: Create a bug report to help us improve pytask-stata
5-
title: "BUG:"
6-
labels: "bug"
3+
name: Bug Report about: Create a bug report to help us improve pytask-stata title:
4+
"BUG:" labels: "bug"
75

8-
---
6+
______________________________________________________________________
97

108
- [ ] I have checked that this issue has not already been reported.
119

1210
- [ ] I have confirmed this bug exists on the latest version of pytask-stata.
1311

14-
- [ ] (optional) I have confirmed this bug exists on the `main` branch of
15-
pytask-stata.
12+
- [ ] (optional) I have confirmed this bug exists on the `main` branch of pytask-stata.
1613

17-
---
14+
______________________________________________________________________
1815

19-
**Note**: Please read [this
20-
guide](https://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports) detailing
21-
how to provide the necessary information for us to reproduce your bug.
16+
**Note**: Please read
17+
[this guide](https://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports)
18+
detailing how to provide the necessary information for us to reproduce your bug.
2219

2320
#### Code Sample, a copy-pastable example
2421

.github/ISSUE_TEMPLATE/documentation.md

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
---
1+
______________________________________________________________________
22

3-
name: Documentation Improvement
4-
about: Report wrong or missing documentation
5-
title: "DOC:"
6-
labels: "documentation"
3+
name: Documentation Improvement about: Report wrong or missing documentation title:
4+
"DOC:" labels: "documentation"
75

8-
---
6+
______________________________________________________________________
97

108
#### Location of the documentation
119

.github/ISSUE_TEMPLATE/enhancement.md

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
---
1+
______________________________________________________________________
22

3-
name: Enhancement
4-
about: Suggest an idea for pytask-stata
5-
title: "ENH:"
6-
labels: "enhancement"
3+
name: Enhancement about: Suggest an idea for pytask-stata title: "ENH:" labels:
4+
"enhancement"
75

8-
---
6+
______________________________________________________________________
97

108
#### Is your feature request related to a problem?
119

12-
Provide a description of what the problem is, e.g. "I wish I could use pytask-stata
13-
to do [...]".
10+
Provide a description of what the problem is, e.g. "I wish I could use pytask-stata to
11+
do \[...\]".
1412

1513
#### Describe the solution you'd like
1614

.github/ISSUE_TEMPLATE/question.md

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1-
---
1+
______________________________________________________________________
22

3-
name: Submit Question
4-
about: Ask a general question about pytask-stata
5-
title: "QST:"
3+
name: Submit Question about: Ask a general question about pytask-stata title: "QST:"
64
labels: "question"
75

8-
---
6+
______________________________________________________________________
97

108
#### Question about pytask-stata
119

12-
**Note**: If you'd still like to submit a question, please read [this guide](
13-
https://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports) detailing how to
14-
provide the necessary information for us to reproduce your question.
10+
**Note**: If you'd still like to submit a question, please read
11+
[this guide](https://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports)
12+
detailing how to provide the necessary information for us to reproduce your question.
1513

1614
```python
1715
# Your code here, if applicable

.pre-commit-config.yaml

+24
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,34 @@ repos:
6868
hooks:
6969
- id: interrogate
7070
args: [-v, --fail-under=40, src, tests]
71+
- repo: https://github.com/executablebooks/mdformat
72+
rev: 0.7.14
73+
hooks:
74+
- id: mdformat
75+
additional_dependencies: [
76+
mdformat-gfm,
77+
mdformat-black,
78+
]
79+
args: [--wrap, "88"]
7180
- repo: https://github.com/codespell-project/codespell
7281
rev: v2.1.0
7382
hooks:
7483
- id: codespell
84+
- repo: https://github.com/pre-commit/mirrors-mypy
85+
rev: 'v0.931'
86+
hooks:
87+
- id: mypy
88+
args: [
89+
--no-strict-optional,
90+
--ignore-missing-imports,
91+
]
92+
additional_dependencies: [
93+
attrs,
94+
click,
95+
types-setuptools
96+
]
97+
pass_filenames: false
98+
language_version: "3.9"
7599
- repo: https://github.com/mgedmin/check-manifest
76100
rev: "0.48"
77101
hooks:

CHANGES.md

+18-25
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,51 @@
11
# Changes
22

3-
This is a record of all past pytask-stata releases and what went into
4-
them in reverse chronological order. Releases follow [semantic
5-
versioning](https://semver.org/) and all releases are available on
6-
[PyPI](https://pypi.org/project/pytask-stata) and
3+
This is a record of all past pytask-stata releases and what went into them in reverse
4+
chronological order. Releases follow [semantic versioning](https://semver.org/) and all
5+
releases are available on [PyPI](https://pypi.org/project/pytask-stata) and
76
[Anaconda.org](https://anaconda.org/conda-forge/pytask-stata).
87

98
## 0.2.0 - 2022-xx-xx
109

11-
- {pull}`20` removes an unnecessary hook implementation.
10+
- {pull}`18` adds typing to the package.
11+
- {pull}`20` removes an unnecessary hook implementation.
1212

1313
## 0.1.2 - 2022-02-08
1414

15-
- {pull}`19` fixes the minimum python and
16-
pytask version.
15+
- {pull}`19` fixes the minimum python and pytask version.
1716

1817
## 0.1.1 - 2022-02-07
1918

20-
- {pull}`16` skips concurrent CI builds.
21-
- {pull}`17` deprecates Python 3.6 and adds
22-
support for Python 3.10.
19+
- {pull}`16` skips concurrent CI builds.
20+
- {pull}`17` deprecates Python 3.6 and adds support for Python 3.10.
2321

2422
## 0.1.0 - 2021-07-21
2523

26-
- {pull}`11` fixes the `README.rst`.
27-
- {pull}`13` replaces versioneer with
28-
setuptools-scm.
29-
- {pull}`14` fixes tests and aligns
30-
pytask-stata with pytask v0.1.0.
24+
- {pull}`11` fixes the `README.rst`.
25+
- {pull}`13` replaces versioneer with setuptools-scm.
26+
- {pull}`14` fixes tests and aligns pytask-stata with pytask v0.1.0.
3127

3228
## 0.0.6 - 2021-03-05
3329

34-
- {pull}`10` fixes the version of the package.
30+
- {pull}`10` fixes the version of the package.
3531

3632
## 0.0.5 - 2021-03-04
3733

38-
- {pull}`7` fix some post-release issues.
39-
- {pull}`9` adds dependencies to `setup.py`.
34+
- {pull}`7` fix some post-release issues.
35+
- {pull}`9` adds dependencies to `setup.py`.
4036

4137
## 0.0.4 - 2021-02-25
4238

43-
- {pull}`6` prepares pytask-stata to be
44-
published on PyPI, adds versioneer and more.
39+
- {pull}`6` prepares pytask-stata to be published on PyPI, adds versioneer and more.
4540

4641
## 0.0.3 - 2021-01-16
4742

48-
- {pull}`4` removes log file handling on UNIX
49-
and raises an error if run in parallel.
43+
- {pull}`4` removes log file handling on UNIX and raises an error if run in parallel.
5044

5145
## 0.0.2 - 2020-10-30
5246

53-
- {pull}`1` makes pytask-stata work with pytask
54-
v0.0.9.
47+
- {pull}`1` makes pytask-stata work with pytask v0.0.9.
5548

5649
## 0.0.1 - 2020-10-04
5750

58-
- Release v0.0.1.
51+
- Release v0.0.1.

README.md

+40-49
Original file line numberDiff line numberDiff line change
@@ -10,39 +10,37 @@
1010
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/pytask-dev/pytask-stata/main.svg)](https://results.pre-commit.ci/latest/github/pytask-dev/pytask-stata/main)
1111
[![image](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
1212

13-
------------------------------------------------------------------------
13+
______________________________________________________________________
1414

15-
Run Stata\'s do-files with pytask.
15+
Run Stata's do-files with pytask.
1616

1717
## Installation
1818

19-
pytask-stata is available on
20-
[PyPI](https://pypi.org/project/pytask-stata) and
21-
[Anaconda.org](https://anaconda.org/conda-forge/pytask-stata). Install
22-
it with
19+
pytask-stata is available on [PyPI](https://pypi.org/project/pytask-stata) and
20+
[Anaconda.org](https://anaconda.org/conda-forge/pytask-stata). Install it with
2321

24-
``` console
22+
```console
2523
$ pip install pytask-stata
2624

2725
# or
2826

2927
$ conda install -c conda-forge pytask-stata
3028
```
3129

32-
You also need to have Stata installed on your system and have the
33-
executable on your system\'s PATH. If you do not know how to do it,
34-
[here](https://superuser.com/a/284351) is an explanation.
30+
You also need to have Stata installed on your system and have the executable on your
31+
system's PATH. If you do not know how to do it, [here](https://superuser.com/a/284351)
32+
is an explanation.
3533

3634
## Usage
3735

38-
Similarly to normal task functions which execute Python code, you define
39-
tasks to execute scripts written in Stata with Python functions. The
40-
difference is that the function body does not contain any logic, but the
41-
decorator tells pytask how to handle the task.
36+
Similarly to normal task functions which execute Python code, you define tasks to
37+
execute scripts written in Stata with Python functions. The difference is that the
38+
function body does not contain any logic, but the decorator tells pytask how to handle
39+
the task.
4240

4341
Here is an example where you want to run `script.do`.
4442

45-
``` python
43+
```python
4644
import pytask
4745

4846

@@ -52,24 +50,23 @@ def task_run_do_file():
5250
pass
5351
```
5452

55-
When executing a do-file, the current working directory changes to the
56-
directory where the script is located. This allows you, for example, to
57-
reference every data set you want to read with a relative path from the
58-
script.
53+
When executing a do-file, the current working directory changes to the directory where
54+
the script is located. This allows you, for example, to reference every data set you
55+
want to read with a relative path from the script.
5956

6057
### Dependencies and Products
6158

62-
Dependencies and products can be added as with a normal pytask task
63-
using the `@pytask.mark.depends_on` and `@pytask.mark.produces`
64-
decorators. which is explained in this
59+
Dependencies and products can be added as with a normal pytask task using the
60+
`@pytask.mark.depends_on` and `@pytask.mark.produces` decorators. which is explained in
61+
this
6562
[tutorial](https://pytask-dev.readthedocs.io/en/stable/tutorials/defining_dependencies_products.html).
6663

6764
### Accessing dependencies and products in the script
6865

69-
The decorator can be used to pass command line arguments to your Stata
70-
executable. For example, pass the path of the product with
66+
The decorator can be used to pass command line arguments to your Stata executable. For
67+
example, pass the path of the product with
7168

72-
``` python
69+
```python
7370
@pytask.mark.stata(script="script.do", options="auto.dta")
7471
@pytask.mark.produces("auto.dta")
7572
def task_run_do_file():
@@ -78,22 +75,21 @@ def task_run_do_file():
7875

7976
And in your `script.do`, you can intercept the value with
8077

81-
``` do
78+
```do
8279
* Intercept command line argument and save to macro named 'produces'.
8380
args produces
8481
8582
sysuse auto, clear
8683
save "`produces'"
8784
```
8885

89-
The relative path inside the do-file works only because the pytask-stata
90-
switches the current working directory to the directory of the do-file
91-
before the task is executed.
86+
The relative path inside the do-file works only because the pytask-stata switches the
87+
current working directory to the directory of the do-file before the task is executed.
9288

93-
To make the task independent from the current working directory, pass
94-
the full path as an command line argument. Here is an example.
89+
To make the task independent from the current working directory, pass the full path as
90+
an command line argument. Here is an example.
9591

96-
``` python
92+
```python
9793
# Absolute path to the build directory.
9894
from src.config import BLD
9995

@@ -106,14 +102,12 @@ def task_run_do_file():
106102

107103
### Repeating tasks with different scripts or inputs
108104

109-
You can also parametrize the execution of scripts, meaning executing
110-
multiple do-files as well as passing different command line arguments to
111-
the same do-file.
105+
You can also parametrize the execution of scripts, meaning executing multiple do-files
106+
as well as passing different command line arguments to the same do-file.
112107

113-
The following task executes two do-files which produce different
114-
outputs.
108+
The following task executes two do-files which produce different outputs.
115109

116-
``` python
110+
```python
117111
for i in range(2):
118112

119113
@pytask.mark.task
@@ -129,25 +123,22 @@ pytask-stata can be configured with the following options.
129123

130124
*`stata_keep_log`*
131125

132-
Use this option to keep the `.log` files which are produced for
133-
every task. This option is useful to debug Stata tasks. Set the
134-
option via the configuration file with
126+
Use this option to keep the `.log` files which are produced for every task. This option
127+
is useful to debug Stata tasks. Set the option via the configuration file with
135128

136129
```toml
137130
[tool.pytask.ini_options]
138131
stata_keep_log = true
139132
```
140133

141-
The option is also available in the command line interface via the
142-
`--stata-keep-log` flag.
143-
134+
The option is also available in the command line interface via the `--stata-keep-log`
135+
flag.
144136

145137
*`stata_check_log_lines`*
146138

147-
Use this option to vary the number of lines in the log file which
148-
are checked for error codes. It also controls the number of lines
149-
displayed on errors. Use any integer greater than zero. Here is the
150-
entry in the configuration file
139+
Use this option to vary the number of lines in the log file which are checked for error
140+
codes. It also controls the number of lines displayed on errors. Use any integer greater
141+
than zero. Here is the entry in the configuration file
151142

152143
```toml
153144
[tool.pytask.ini_options]
@@ -156,7 +147,7 @@ stata_check_log_lines = 10
156147

157148
and here via the command line interface
158149

159-
``` console
150+
```console
160151
$ pytask build --stata-check-log-lines 10
161152
```
162153

0 commit comments

Comments
 (0)