Skip to content

Commit

Permalink
Merge pull request #446 from basedosdados/fix-action-pylint
Browse files Browse the repository at this point in the history
fix: atualizar o workflow lint python
  • Loading branch information
vncsna authored Sep 27, 2023
2 parents 72abfc8 + e23a3c2 commit aba5155
Show file tree
Hide file tree
Showing 68 changed files with 978 additions and 668 deletions.
5 changes: 2 additions & 3 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[flake8]
ignore = E203,F401,F403,W503,E501,E266
exclude =
*cookiecutter*
max-line-length = 100
exclude = *cookiecutter*
max-line-length = 100
39 changes: 16 additions & 23 deletions .github/workflows/lint_python.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,24 @@ jobs:
name: Lint Python
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.8.x"
- name: Set up Poetry and upgrade pip
python-version: "3.9.x"

- name: Set up poetry and upgrade pip
run: |
pip install -U pip poetry
- name: Install flows
run: |
pip install --prefer-binary .
- name: Lint flows
uses: gabriel-milan/action-pylint@v1
with:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
path: "pipelines/"
fail: true
pr-message: true
- name: Install Pytest
run: |
pip install pytest
- name: Lint tests
uses: gabriel-milan/action-pylint@v1
with:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
path: "tests/"
fail: true
pr-message: true
pip install isort
pip install black
pip install autoflake
pip install flake8
- name: Install this package
run: poetry install

- name: Lint source code
run: poetry run lint
1 change: 0 additions & 1 deletion .github/workflows/scripts/register_flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
)
import glob
import hashlib
import importlib
import json
import os
from pathlib import Path
Expand Down
27 changes: 15 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-added-large-files # prevents adding large files
- id: detect-private-key # detects private keys
- id: fix-byte-order-marker # fixes BOM
- id: fix-encoding-pragma # fixes encoding pragma
- id: no-commit-to-branch # prevents committing to protected branches
- id: trailing-whitespace # prevents trailing whitespace
- repo: https://github.com/psf/black
- id: check-added-large-files # prevents adding large files
- id: detect-private-key # detects private keys
- id: fix-byte-order-marker # fixes BOM
- id: fix-encoding-pragma # fixes encoding pragma
- id: no-commit-to-branch # prevents committing to protected branches
- id: trailing-whitespace # prevents trailing whitespace
- repo: https://github.com/psf/black
rev: 23.9.1
hooks:
- id: black

- id: black
exclude: 'pipelines\/\{\{cookiecutter\.project_name\}\}.*'
- repo: https://github.com/PyCQA/flake8
- repo: https://github.com/PyCQA/autoflake
rev: v2.2.1
hooks:
- id: autoflake
- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
hooks:
- id: flake8
- id: flake8
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Get the executables we're using
POETRY=$(shell which poetry)
PYTHON=$(shell poetry run which python)

# `make install`: installs dependencies
.PHONY: install
install:
$(POETRY) install

# `make install`: installs pre-commit
.PHONY: install_precommit
install_precommit:
$(POETRY) run pre-commit install --install-hooks
2 changes: 1 addition & 1 deletion pipelines/datasets/br_anatel_banda_larga_fixa/schedules.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Schedules for dataset br_anatel_banda_larga_fixa
"""

from datetime import timedelta, datetime
from datetime import datetime
from prefect.schedules import Schedule
from prefect.schedules.clocks import CronClock
from prefect.schedules.clocks import IntervalClock
Expand Down
2 changes: 0 additions & 2 deletions pipelines/datasets/br_anatel_banda_larga_fixa/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
"""
import pandas as pd
import numpy as np
from zipfile import ZipFile
from pathlib import Path
import os

from datetime import datetime, timedelta
Expand Down
1 change: 0 additions & 1 deletion pipelines/datasets/br_anatel_banda_larga_fixa/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import os
import pandas as pd
import numpy as np
from datetime import datetime, timedelta
from pathlib import Path


Expand Down
2 changes: 1 addition & 1 deletion pipelines/datasets/br_anatel_telefonia_movel/schedules.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"""
Schedules for dataset br_anatel_telefonia_movel
"""
from datetime import timedelta, datetime
from datetime import datetime
from prefect.schedules import Schedule
from prefect.schedules.clocks import IntervalClock
from pipelines.constants import constants
Expand Down
1 change: 0 additions & 1 deletion pipelines/datasets/br_anatel_telefonia_movel/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import os
import pandas as pd
import numpy as np
from datetime import datetime, timedelta
from pathlib import Path


Expand Down
2 changes: 1 addition & 1 deletion pipelines/datasets/br_anp_precos_combustiveis/schedules.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Schedules for br_anp_precos_combustiveis
"""

from datetime import timedelta, datetime
from datetime import datetime
from prefect.schedules import Schedule
from prefect.schedules.clocks import CronClock
from pipelines.constants import constants
Expand Down
2 changes: 1 addition & 1 deletion pipelines/datasets/br_ans_beneficiario/flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""


from datetime import datetime, timedelta
from datetime import timedelta
from prefect.run_configs import KubernetesRun
from prefect.storage import GCS
from pipelines.constants import constants
Expand Down
2 changes: 1 addition & 1 deletion pipelines/datasets/br_ans_beneficiario/schedules.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""


from datetime import timedelta, datetime
from datetime import datetime
from prefect.schedules import Schedule
from pipelines.constants import constants
from prefect.schedules.clocks import CronClock
Expand Down
5 changes: 0 additions & 5 deletions pipelines/datasets/br_ans_beneficiario/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,12 @@
from bs4 import BeautifulSoup
import re
import pandas as pd
from multiprocessing import Pool
from datetime import datetime
from loguru import logger
from pathlib import Path
from functools import reduce
from prefect import task
import os
from tqdm import tqdm
import zipfile
import requests
from glob import glob
from pipelines.datasets.br_ans_beneficiario.utils import (
download_unzip_csv,
get_url_from_template,
Expand Down
4 changes: 0 additions & 4 deletions pipelines/datasets/br_ans_beneficiario/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,15 @@

# from multiprocessing import Pool
from loguru import logger
from pathlib import Path


from datetime import datetime
from io import BytesIO
import os
from tqdm import tqdm

# import tempfile
from pipelines.datasets.br_ans_beneficiario.constants import constants as ans_constants
import zipfile
import requests
from functools import reduce
from dateutil.relativedelta import relativedelta
from pipelines.utils.utils import (
log,
Expand Down
1 change: 0 additions & 1 deletion pipelines/datasets/br_b3_cotacoes/constants.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
from enum import Enum
from datetime import datetime, timedelta


class constants(Enum): # pylint: disable=c0103
Expand Down
2 changes: 1 addition & 1 deletion pipelines/datasets/br_b3_cotacoes/schedules.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
from datetime import timedelta, datetime
from datetime import datetime
from prefect.schedules import Schedule
from prefect.schedules.clocks import CronClock
from pipelines.constants import constants
Expand Down
2 changes: 1 addition & 1 deletion pipelines/datasets/br_bcb_agencia/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import os
import pandas as pd
from datetime import timedelta, datetime
from datetime import timedelta

from pipelines.datasets.br_bcb_agencia.constants import (
constants as agencia_constants,
Expand Down
2 changes: 1 addition & 1 deletion pipelines/datasets/br_bcb_estban/flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Flows for br_bcb_estban
"""

from datetime import datetime, timedelta
from datetime import timedelta
from prefect.run_configs import KubernetesRun
from prefect.storage import GCS
from prefect import Parameter, case
Expand Down
3 changes: 1 addition & 2 deletions pipelines/datasets/br_bcb_estban/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@
import pandas as pd
import os
import basedosdados as bd
import glob

from pipelines.constants import constants
from pipelines.datasets.br_bcb_estban.constants import (
constants as br_bcb_estban_constants,
)
from datetime import datetime, timedelta
from datetime import timedelta

from pipelines.utils.utils import (
clean_dataframe,
Expand Down
1 change: 0 additions & 1 deletion pipelines/datasets/br_bcb_taxa_cambio/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
Tasks for br_bcb_indicadores
"""

import datetime
from pipelines.utils.utils import log, to_partitions
from prefect import task
import pandas as pd
Expand Down
3 changes: 1 addition & 2 deletions pipelines/datasets/br_bcb_taxa_cambio/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
import pandas as pd
import datetime
import pytz
from datetime import timedelta
import os
from io import BytesIO, StringIO
from io import BytesIO
import time as tm
from pipelines.datasets.br_bcb_taxa_cambio.constants import constants as bcb_constants
from pipelines.utils.utils import log
Expand Down
2 changes: 1 addition & 1 deletion pipelines/datasets/br_bd_indicadores/flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Flows for br_bd_indicadores
"""
# pylint: disable=invalid-name
from datetime import timedelta, datetime
from datetime import timedelta

from prefect import Parameter, case
from prefect.run_configs import KubernetesRun
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"""
Flows for br_cgu_terceirizados
"""
from datetime import datetime, timedelta
from datetime import timedelta

from prefect.run_configs import KubernetesRun
from prefect.storage import GCS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Flows for br_cvm_administradores_carteira
"""
# pylint: disable=C0103, E1123, invalid-name
from datetime import datetime, timedelta
from datetime import timedelta

from prefect import Parameter, case
from prefect.run_configs import KubernetesRun
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from prefect import task
from unidecode import unidecode
import basedosdados as bd
from datetime import datetime
from pipelines.utils.utils import log


Expand Down
2 changes: 1 addition & 1 deletion pipelines/datasets/br_cvm_fi/schedules.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Schedules for br_cvm_fi
"""

from datetime import timedelta, datetime
from datetime import datetime
from prefect.schedules import Schedule
from prefect.schedules.clocks import IntervalClock
from pipelines.constants import constants
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Flows for br_cvm_oferta_publica_distribuicao
"""
# pylint: disable=C0103, E1123, invalid-name
from datetime import datetime, timedelta
from datetime import timedelta

from prefect.run_configs import KubernetesRun
from prefect.storage import GCS
Expand Down
2 changes: 1 addition & 1 deletion pipelines/datasets/br_fgv_igp/flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""

# pylint: disable=invalid-name
from datetime import timedelta, datetime
from datetime import timedelta
from pathlib import Path

from prefect import Parameter, case
Expand Down
1 change: 0 additions & 1 deletion pipelines/datasets/br_ibge_pnadc/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import pandas as pd
import numpy as np
from prefect import task
from datetime import datetime

from pipelines.utils.utils import log
from pipelines.datasets.br_ibge_pnadc.constants import constants as pnad_constants
Expand Down
2 changes: 1 addition & 1 deletion pipelines/datasets/br_inmet_bdmep/schedules.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
###############################################################################


from datetime import timedelta, datetime
from datetime import datetime
from prefect.schedules import Schedule
from prefect.schedules.clocks import IntervalClock
from pipelines.constants import constants
Expand Down
1 change: 0 additions & 1 deletion pipelines/datasets/br_inmet_bdmep/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import os
import numpy as np
import glob
from datetime import datetime, time
from prefect import task
from pipelines.datasets.br_inmet_bdmep.constants import constants as inmet_constants

Expand Down
2 changes: 1 addition & 1 deletion pipelines/datasets/br_me_cnpj/schedules.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

###############################################################################
from prefect.schedules.clocks import CronClock
from datetime import timedelta, datetime
from datetime import datetime
from prefect.schedules import Schedule
from pipelines.constants import constants

Expand Down
3 changes: 1 addition & 2 deletions pipelines/datasets/br_me_cnpj/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@
)
import os
import requests
import zipfile
import pandas as pd
from datetime import datetime, timedelta
from datetime import datetime
from tqdm import tqdm

ufs = constants_cnpj.UFS.value
Expand Down
Loading

0 comments on commit aba5155

Please sign in to comment.