diff --git a/.flake8 b/.flake8 index d26a0ad..01eae65 100644 --- a/.flake8 +++ b/.flake8 @@ -19,6 +19,6 @@ ignore = B905, S113 max-complexity = 16 -max-line-length = 99 +max-line-length = 120 exclude = .git,__pycache__,docs/source/conf.py,old,build,dist,tests, src/folio_data_import/report_blurbs.py statistics = True diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 5f1aa07..4c4bd16 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -30,4 +30,4 @@ jobs: poetry install --with dev - name: Run tests run: | - poetry run pytest \ No newline at end of file + poetry run pytest diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index dc0c15d..f893e5e 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -48,4 +48,4 @@ jobs: run: | poetry build - name: Publish - uses: pypa/gh-action-pypi-publish@release/v1 \ No newline at end of file + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..64d7a99 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,22 @@ +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.3.0 + hooks: + - id: check-yaml + - id: end-of-file-fixer + - id: check-ast + - id: check-added-large-files + - id: check-docstring-first + - id: requirements-txt-fixer +- repo: local + hooks: + - id: black + name: black + language: system + entry: black + types: [python] + - id: flake8 + name: flake8 + language: system + entry: flake8 + types: [python] diff --git a/LICENSE b/LICENSE index d8bf188..6111239 100644 --- a/LICENSE +++ b/LICENSE @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +SOFTWARE. diff --git a/pyproject.toml b/pyproject.toml index 696d243..06347e6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,10 +22,17 @@ inquirer = "^3.4.0" tqdm = "^4.66.5" tabulate = "^0.9.0" aiofiles = "^24.1.0" +flake8-black = "^0.3.6" +flake8-bugbear = "^24.8.19" +flake8-bandit = "^4.1.1" +flake8-isort = "^6.1.1" +flake8-docstrings = "^1.7.0" [tool.poetry.group.dev.dependencies] pytest = "^8.3.2" +flake8 = "^7.1.1" +black = "^24.8.0" [build-system] requires = ["poetry-core"] diff --git a/requirements.txt b/requirements.txt index 65e0e5f..89d820e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,30 +1,57 @@ -aiofiles==24.1.0 ; python_version >= "3.10" and python_version < "4.0" -ansicon==1.89.0 ; python_version >= "3.10" and python_version < "4.0" and platform_system == "Windows" -anyio==4.4.0 ; python_version >= "3.10" and python_version < "4.0" -blessed==1.20.0 ; python_version >= "3.10" and python_version < "4.0" -certifi==2024.7.4 ; python_version >= "3.10" and python_version < "4.0" -colorama==0.4.6 ; python_version >= "3.10" and python_version < "4.0" and platform_system == "Windows" -editor==1.6.6 ; python_version >= "3.10" and python_version < "4.0" -exceptiongroup==1.2.2 ; python_version >= "3.10" and python_version < "3.11" -folioclient==0.60.5 ; python_version >= "3.10" and python_version < "4.0" -h11==0.14.0 ; python_version >= "3.10" and python_version < "4.0" -httpcore==0.16.3 ; python_version >= "3.10" and python_version < "4.0" -httpx==0.23.3 ; python_version >= "3.10" and python_version < "4.0" -idna==3.7 ; python_version >= "3.10" and python_version < "4.0" -inquirer==3.4.0 ; python_version >= "3.10" and python_version < "4.0" -jinxed==1.3.0 ; python_version >= "3.10" and python_version < "4.0" and platform_system == "Windows" -py-openapi-schema-to-json-schema==0.0.3 ; python_version >= "3.10" and python_version < "4.0" -pyhumps==3.8.0 ; python_version >= "3.10" and python_version < "4.0" -pymarc==5.2.2 ; python_version >= "3.10" and python_version < "4.0" -python-dateutil==2.9.0.post0 ; python_version >= "3.10" and python_version < "4.0" -pyyaml==6.0.2 ; python_version >= "3.10" and python_version < "4.0" -readchar==4.2.0 ; python_version >= "3.10" and python_version < "4.0" -rfc3986[idna2008]==1.5.0 ; python_version >= "3.10" and python_version < "4.0" -runs==1.2.2 ; python_version >= "3.10" and python_version < "4.0" -six==1.16.0 ; python_version >= "3.10" and python_version < "4.0" -sniffio==1.3.1 ; python_version >= "3.10" and python_version < "4.0" -tabulate==0.9.0 ; python_version >= "3.10" and python_version < "4.0" -tqdm==4.66.5 ; python_version >= "3.10" and python_version < "4.0" -typing-extensions==4.12.2 ; python_version >= "3.10" and python_version < "3.11" -wcwidth==0.2.13 ; python_version >= "3.10" and python_version < "4.0" -xmod==1.8.1 ; python_version >= "3.10" and python_version < "4.0" +aiofiles==24.1.0 ; python_version >= "3.9" and python_version < "4.0" +ansicon==1.89.0 ; python_version >= "3.9" and python_version < "4.0" and platform_system == "Windows" +anyio==4.4.0 ; python_version >= "3.9" and python_version < "4.0" +attrs==24.2.0 ; python_version >= "3.9" and python_version < "4.0" +bandit==1.7.9 ; python_version >= "3.9" and python_version < "4.0" +black==24.8.0 ; python_version >= "3.9" and python_version < "4.0" +blessed==1.20.0 ; python_version >= "3.9" and python_version < "4.0" +certifi==2024.7.4 ; python_version >= "3.9" and python_version < "4.0" +click==8.1.7 ; python_version >= "3.9" and python_version < "4.0" +colorama==0.4.6 ; python_version >= "3.9" and python_version < "4.0" and platform_system == "Windows" +editor==1.6.6 ; python_version >= "3.9" and python_version < "4.0" +exceptiongroup==1.2.2 ; python_version >= "3.9" and python_version < "3.11" +flake8==7.1.1 ; python_version >= "3.9" and python_version < "4.0" +flake8-bandit==4.1.1 ; python_version >= "3.9" and python_version < "4.0" +flake8-black==0.3.6 ; python_version >= "3.9" and python_version < "4.0" +flake8-bugbear==24.8.19 ; python_version >= "3.9" and python_version < "4.0" +flake8-docstrings==1.7.0 ; python_version >= "3.9" and python_version < "4.0" +flake8-isort==6.1.1 ; python_version >= "3.9" and python_version < "4.0" +folioclient==0.60.5 ; python_version >= "3.9" and python_version < "4.0" +h11==0.14.0 ; python_version >= "3.9" and python_version < "4.0" +httpcore==0.16.3 ; python_version >= "3.9" and python_version < "4.0" +httpx==0.23.3 ; python_version >= "3.9" and python_version < "4.0" +idna==3.7 ; python_version >= "3.9" and python_version < "4.0" +inquirer==3.4.0 ; python_version >= "3.9" and python_version < "4.0" +isort==5.13.2 ; python_version >= "3.9" and python_version < "4.0" +jinxed==1.3.0 ; python_version >= "3.9" and python_version < "4.0" and platform_system == "Windows" +markdown-it-py==3.0.0 ; python_version >= "3.9" and python_version < "4.0" +mccabe==0.7.0 ; python_version >= "3.9" and python_version < "4.0" +mdurl==0.1.2 ; python_version >= "3.9" and python_version < "4.0" +mypy-extensions==1.0.0 ; python_version >= "3.9" and python_version < "4.0" +packaging==24.1 ; python_version >= "3.9" and python_version < "4.0" +pathspec==0.12.1 ; python_version >= "3.9" and python_version < "4.0" +pbr==6.1.0 ; python_version >= "3.9" and python_version < "4.0" +platformdirs==4.2.2 ; python_version >= "3.9" and python_version < "4.0" +py-openapi-schema-to-json-schema==0.0.3 ; python_version >= "3.9" and python_version < "4.0" +pycodestyle==2.12.1 ; python_version >= "3.9" and python_version < "4.0" +pydocstyle==6.3.0 ; python_version >= "3.9" and python_version < "4.0" +pyflakes==3.2.0 ; python_version >= "3.9" and python_version < "4.0" +pygments==2.18.0 ; python_version >= "3.9" and python_version < "4.0" +pyhumps==3.8.0 ; python_version >= "3.9" and python_version < "4.0" +pymarc==5.2.2 ; python_version >= "3.9" and python_version < "4.0" +python-dateutil==2.9.0.post0 ; python_version >= "3.9" and python_version < "4.0" +pyyaml==6.0.2 ; python_version >= "3.9" and python_version < "4.0" +readchar==4.2.0 ; python_version >= "3.9" and python_version < "4.0" +rfc3986[idna2008]==1.5.0 ; python_version >= "3.9" and python_version < "4.0" +rich==13.8.0 ; python_version >= "3.9" and python_version < "4.0" +runs==1.2.2 ; python_version >= "3.9" and python_version < "4.0" +six==1.16.0 ; python_version >= "3.9" and python_version < "4.0" +sniffio==1.3.1 ; python_version >= "3.9" and python_version < "4.0" +snowballstemmer==2.2.0 ; python_version >= "3.9" and python_version < "4.0" +stevedore==5.3.0 ; python_version >= "3.9" and python_version < "4.0" +tabulate==0.9.0 ; python_version >= "3.9" and python_version < "4.0" +tomli==2.0.1 ; python_version >= "3.9" and python_version < "3.11" +tqdm==4.66.5 ; python_version >= "3.9" and python_version < "4.0" +typing-extensions==4.12.2 ; python_version >= "3.9" and python_version < "3.11" +wcwidth==0.2.13 ; python_version >= "3.9" and python_version < "4.0" +xmod==1.8.1 ; python_version >= "3.9" and python_version < "4.0" diff --git a/src/folio_data_import/UserImport.py b/src/folio_data_import/UserImport.py index e513453..acdc888 100644 --- a/src/folio_data_import/UserImport.py +++ b/src/folio_data_import/UserImport.py @@ -243,11 +243,11 @@ async def map_departments(self, user_obj, line_number) -> None: mapped_departments.append(self.department_map[department]) except KeyError: print( - f'Row {line_number}: Department "{department}" not found, ' + f'Row {line_number}: Department "{department}" not found, ' # noqa: B907 f"excluding department from user" ) await self.logfile.write( - f'Row {line_number}: Department "{department}" not found, ' + f'Row {line_number}: Department "{department}" not found, ' # noqa: B907 f"excluding department from user\n" ) user_obj["departments"] = mapped_departments diff --git a/src/folio_data_import/__main__.py b/src/folio_data_import/__main__.py index debb4de..3a26f8c 100644 --- a/src/folio_data_import/__main__.py +++ b/src/folio_data_import/__main__.py @@ -45,7 +45,10 @@ async def main(): parser.add_argument( "--consolidate", action="store_true", - help="Consolidate records into a single job. Default is to create a new job for each MARC file.", + help=( + "Consolidate records into a single job. " + "Default is to create a new job for each MARC file." + ), ) parser.add_argument( "--no-progress", @@ -96,7 +99,10 @@ async def main(): print("Error importing files: " + str(e)) raise elif args.record_type.lower() == "users": - print("User import not yet implemented. Run UserImport.py directly or use folio-user-import CLI.") + print( + "User import not yet implemented. Run UserImport.py directly " + "or use folio-user-import CLI." + ) else: print("Record type not supported. Supported types are: MARC21") diff --git a/tests/__init__.py b/tests/__init__.py index ddec794..bbb1646 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -3,4 +3,4 @@ PROJECT_PATH = os.getcwd() SOURCE_PATH = os.path.join(PROJECT_PATH, "src") -sys.path.append(SOURCE_PATH) \ No newline at end of file +sys.path.append(SOURCE_PATH) diff --git a/tests/test_marc_data_import.py b/tests/test_marc_data_import.py index 5281b75..5c15a58 100644 --- a/tests/test_marc_data_import.py +++ b/tests/test_marc_data_import.py @@ -3,12 +3,14 @@ from folioclient import FolioClient import pytest + @pytest.fixture def folio_client(): folio_client = Mock(spec=FolioClient) return folio_client + @pytest.fixture def marc_import_job(folio_client): marc_import_job = Mock(spec=MARCImportJob) - return marc_import_job \ No newline at end of file + return marc_import_job