Skip to content

Commit

Permalink
Merge branch 'main' into pr/40
Browse files Browse the repository at this point in the history
  • Loading branch information
GalenReich committed Oct 24, 2024
2 parents c4e0163 + b993491 commit 58501d3
Show file tree
Hide file tree
Showing 12 changed files with 382 additions and 208 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
]
}
},
"postCreateCommand": "poetry install"
"postCreateCommand": "poetry install && poetry run pre-commit install"
}
14 changes: 14 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
repos:
- repo: local
hooks:
- id: black
name: black
entry: poetry run black
language: system
types: [python]

- id: isort
name: isort
entry: poetry run isort
language: system
types: [python]
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,13 +226,16 @@ pip install poetry

# Install dependencies
poetry install

# Set up pre-commit hooks to keep your code formatted
poetry run pre-commit install
```

Check out [Important commands](#important-commands) below for next steps.

### Developing using a GitHub Codespace

This project uses a custom Development Container supported by GitHub Codespaces. Creating a new Codespace automatically takes care of installing all supported Python interpreters, the Poetry package manager, and Python dependencies for you.
This project uses a custom Development Container supported by GitHub Codespaces. Creating a new Codespace automatically takes care of installing all supported Python interpreters, the Poetry package manager, Python dependencies, and pre-commit hooks for you.

To create a new Codespace:
1. Click on the `<> Code` dropdown on the GitHub UI.
Expand Down
3 changes: 2 additions & 1 deletion edgar_tool/__main__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from edgar_tool.cli import SecEdgarScraperCli
import fire

from edgar_tool.cli import SecEdgarScraperCli


def main():
fire.Fire(SecEdgarScraperCli)
Expand Down
5 changes: 3 additions & 2 deletions edgar_tool/cli.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import sys
import time
from datetime import date, timedelta, datetime
from datetime import date, datetime, timedelta
from typing import List, Optional
from warnings import warn

from edgar_tool.constants import (
SUPPORTED_OUTPUT_EXTENSIONS,
TEXT_SEARCH_CATEGORY_FORM_GROUPINGS,
TEXT_SEARCH_FILING_VS_MAPPING_CATEGORIES_MAPPING,
)
from edgar_tool.page_fetcher import NoResultsFoundError
from edgar_tool.rss import fetch_rss_feed
from edgar_tool.text_search import EdgarTextSearcher
from edgar_tool.utils import parse_location_input
from edgar_tool.page_fetcher import NoResultsFoundError


def _validate_text_search_args(
Expand Down
6 changes: 2 additions & 4 deletions edgar_tool/io.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import csv
import json
from typing import List, Dict, Any, Iterator
from typing import Any, Dict, Iterator, List

import jsonlines

from edgar_tool.constants import (
SUPPORTED_OUTPUT_EXTENSIONS,
)
from edgar_tool.constants import SUPPORTED_OUTPUT_EXTENSIONS


def write_results_to_file(
Expand Down
4 changes: 2 additions & 2 deletions edgar_tool/page_fetcher.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import time
import uuid
from random import uniform
from typing import Callable, Any, Optional
from typing import Any, Callable, Optional

from tenacity import retry, wait_fixed, stop_after_attempt
import requests
from tenacity import retry, stop_after_attempt, wait_fixed


def fetch_page(
Expand Down
2 changes: 1 addition & 1 deletion edgar_tool/rss.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json
import uuid
from pathlib import Path
from typing import List, Any, Dict, Iterator, Tuple
from typing import Any, Dict, Iterator, List, Tuple

import requests
import xmltodict
Expand Down
17 changes: 8 additions & 9 deletions edgar_tool/text_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,23 @@
import urllib.parse
from datetime import date, timedelta
from math import ceil
from typing import List, Optional, Dict, Any, Iterator
from typing import Any, Dict, Iterator, List, Optional


from edgar_tool.page_fetcher import (
fetch_page,
PageCheckFailedError,
ResultsTableNotFoundError,
NoResultsFoundError,
)
from edgar_tool.constants import (
TEXT_SEARCH_BASE_URL,
TEXT_SEARCH_CATEGORY_FORM_GROUPINGS,
TEXT_SEARCH_SPLIT_BATCHES_NUMBER,
TEXT_SEARCH_CSV_FIELDS_NAMES,
TEXT_SEARCH_FORM_MAPPING,
TEXT_SEARCH_LOCATIONS_MAPPING,
TEXT_SEARCH_SPLIT_BATCHES_NUMBER,
)
from edgar_tool.io import write_results_to_file
from edgar_tool.page_fetcher import (
fetch_page,
PageCheckFailedError,
ResultsTableNotFoundError,
NoResultsFoundError,
)
from edgar_tool.utils import split_date_range_in_n, unpack_singleton_list


Expand Down
3 changes: 2 additions & 1 deletion edgar_tool/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import re
from datetime import date
from typing import Any, Iterator, Dict, List, Union, Optional
from typing import Any, Dict, Iterator, List, Optional, Union

from edgar_tool.constants import TEXT_SEARCH_LOCATIONS_MAPPING


Expand Down
512 changes: 330 additions & 182 deletions poetry.lock

Large diffs are not rendered by default.

17 changes: 13 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,28 @@ keywords=["scraper", "edgar", "finance", "sec"]
edgar-tool = "edgar_tool.__main__:main"

[tool.poetry.dependencies]
python = "^3.9"
tenacity = "^8.2"
fire = "^0.5"
jsonlines = "^4.0"
python = "^3.9"
requests = "^2.31"
tenacity = "^8.2"
xmltodict = "^0.13"
pytest = "^8.2.2"

[tool.poetry.group.dev.dependencies]
black = "^24.2.0"
tox = "^4.16.0"
black = "24.3.0"
isort = "5.13.2"
pre-commit = "^3.8.0"
pytest = "^8.2.2"
tox = "^4.16.0"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.isort]
profile = "black"
line_length = 88 # Should always match tool.black

[tool.black]
line-length = 88 # black's default

0 comments on commit 58501d3

Please sign in to comment.