diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index dcbd1e73..77af3699 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -15,17 +15,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - - name: Set up python - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - architecture: ${{ matrix.arch }} - - name: Set up poetry and upgrade pip - run: pip install -U pip poetry - - name: Install this package - run: poetry install - name: Lint source code - run: poetry run lint + uses: chartboost/ruff-action@v1 - name: Lint pull request title uses: amannn/action-semantic-pull-request@v5 env: @@ -50,8 +41,8 @@ jobs: - name: Set up python uses: actions/setup-python@v2 with: - python-version: ${{ matrix.python-version }} architecture: ${{ matrix.arch }} + python-version: ${{ matrix.python-version }} - name: Set up poetry and upgrade pip run: pip install -U pip poetry - name: Install this package diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 787e5298..c066d951 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,19 +22,9 @@ repos: rev: v1.29.0 hooks: - id: yamllint - - repo: https://github.com/psf/black - rev: 22.3.0 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.2.0 hooks: - - id: black - - repo: https://github.com/pycqa/isort - rev: 5.12.0 - hooks: - - id: isort - - repo: https://github.com/PyCQA/autoflake - rev: v2.2.0 - hooks: - - id: autoflake - - repo: https://github.com/PyCQA/flake8 - rev: 4.0.1 - hooks: - - id: flake8 + - id: ruff + args: [--fix] + - id: ruff-format diff --git a/bd_api/apps/api/v1/admin.py b/bd_api/apps/api/v1/admin.py index 7cca3f2b..533da1d9 100644 --- a/bd_api/apps/api/v1/admin.py +++ b/bd_api/apps/api/v1/admin.py @@ -103,7 +103,9 @@ def get_formset(self, request, obj=None, **kwargs): def formfield_for_foreignkey(self, db_field, request, **kwargs): """Limit the observation level queryset to the parent object""" if db_field.name == "observation_level": - kwargs["queryset"] = ObservationLevel.objects.filter(table=self.parent_inline_obj) + kwargs["queryset"] = ObservationLevel.objects.filter( + table=self.parent_inline_obj + ) return super().formfield_for_foreignkey(db_field, request, **kwargs) @@ -236,7 +238,9 @@ class UpdateInline(admin.StackedInline): ################################################################################ -def update_table_metadata(modeladmin: ModelAdmin, request: HttpRequest, queryset: QuerySet): +def update_table_metadata( + modeladmin: ModelAdmin, request: HttpRequest, queryset: QuerySet +): """Update the metadata of selected tables in the admin""" if str(modeladmin) == "v1.TableAdmin": tables = queryset.all() @@ -451,10 +455,12 @@ class DatasetAdmin(OrderedInlineModelAdminMixin, TabbedTranslationAdmin): def related_objects(self, obj): return format_html( - "{1} {2}", # noqa pylint: disable=line-too-long + "{1} {2}", obj.id, obj.tables.count(), - " ".join(["tables" if obj.tables.count() > 1 else "table", "(click to add)"]), + " ".join( + ["tables" if obj.tables.count() > 1 else "table", "(click to add)"] + ), ) related_objects.short_description = "Tables" @@ -548,7 +554,9 @@ def changeform_view(self, request, object_id=None, form_url="", extra_context=No { "id": observation.id, "entity": observation.entity.name if observation.entity else "", - "columns": "".join([column.name for column in observation.columns.all()]), + "columns": "".join( + [column.name for column in observation.columns.all()] + ), } ) @@ -572,7 +580,9 @@ def related_columns(self, obj): "{1} {2}", obj.id, obj.columns.count(), - " ".join(["columns" if obj.columns.count() > 1 else "column", "(click to add)"]), + " ".join( + ["columns" if obj.columns.count() > 1 else "column", "(click to add)"] + ), ) related_columns.short_description = "Columns" @@ -582,11 +592,11 @@ def related_coverages(self, obj): lines = [] for datetimerange in qs: lines.append( - 'Date Time Range', # noqa pylint: disable=line-too-long + 'Date Time Range', datetimerange.pk, ) return format_html( - 'Date Time Range', # noqa pylint: disable=line-too-long + 'Date Time Range', obj.datetimerange.slug, ) diff --git a/bd_api/apps/api/v1/models.py b/bd_api/apps/api/v1/models.py index 24326f62..af729698 100644 --- a/bd_api/apps/api/v1/models.py +++ b/bd_api/apps/api/v1/models.py @@ -1,8 +1,4 @@ # -*- coding: utf-8 -*- -# pylint: disable=too-few-public-methods,too-many-lines -""" -Models for API v1 -""" import calendar import json import os @@ -277,7 +273,9 @@ class Key(BaseModel): """ id = models.UUIDField(primary_key=True, default=uuid4) - dictionary = models.ForeignKey("Dictionary", on_delete=models.CASCADE, related_name="keys") + dictionary = models.ForeignKey( + "Dictionary", on_delete=models.CASCADE, related_name="keys" + ) name = models.CharField(max_length=255) value = models.CharField(max_length=255) @@ -436,7 +434,9 @@ class Organization(BaseModel): slug = models.SlugField(unique=False, max_length=255) name = models.CharField(max_length=255) description = models.TextField(blank=True, null=True) - area = models.ForeignKey("Area", on_delete=models.CASCADE, related_name="organizations") + area = models.ForeignKey( + "Area", on_delete=models.CASCADE, related_name="organizations" + ) created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) website = models.URLField(blank=True, null=True, max_length=255) @@ -604,8 +604,12 @@ def coverage(self): continue date_time = get_date_time(date_times) - start_year = date_time.start_year if date_time.start_year else start_year - start_month = date_time.start_month if date_time.start_month else start_month + start_year = ( + date_time.start_year if date_time.start_year else start_year + ) + start_month = ( + date_time.start_month if date_time.start_month else start_month + ) start_day = date_time.start_day if date_time.start_day else start_day end_year = date_time.end_year if date_time.end_year else end_year end_month = date_time.end_month if date_time.end_month else end_month @@ -616,7 +620,9 @@ def coverage(self): date_time.start_month or 1, date_time.start_day or 1, ) - start_date = new_start_date if new_start_date < start_date else start_date + start_date = ( + new_start_date if new_start_date < start_date else start_date + ) new_end_date = datetime( date_time.end_year or 1, date_time.end_month or 1, @@ -631,8 +637,12 @@ def coverage(self): continue date_time = get_date_time(date_times) - start_year = date_time.start_year if date_time.start_year else start_year - start_month = date_time.start_month if date_time.start_month else start_month + start_year = ( + date_time.start_year if date_time.start_year else start_year + ) + start_month = ( + date_time.start_month if date_time.start_month else start_month + ) start_day = date_time.start_day if date_time.start_day else start_day end_year = date_time.end_year if date_time.end_year else end_year end_month = date_time.end_month if date_time.end_month else end_month @@ -643,7 +653,9 @@ def coverage(self): date_time.start_month or 1, date_time.start_day or 1, ) - start_date = new_start_date if new_start_date < start_date else start_date + start_date = ( + new_start_date if new_start_date < start_date else start_date + ) new_end_date = datetime( date_time.end_year or 1, date_time.end_month or 1, @@ -658,8 +670,12 @@ def coverage(self): continue date_time = get_date_time(date_times) - start_year = date_time.start_year if date_time.start_year else start_year - start_month = date_time.start_month if date_time.start_month else start_month + start_year = ( + date_time.start_year if date_time.start_year else start_year + ) + start_month = ( + date_time.start_month if date_time.start_month else start_month + ) start_day = date_time.start_day if date_time.start_day else start_day end_year = date_time.end_year if date_time.end_year else end_year end_month = date_time.end_month if date_time.end_month else end_month @@ -670,7 +686,9 @@ def coverage(self): date_time.start_month or 1, date_time.start_day or 1, ) - start_date = new_start_date if new_start_date < start_date else start_date + start_date = ( + new_start_date if new_start_date < start_date else start_date + ) new_end_date = datetime( date_time.end_year or 1, date_time.end_month or 1, @@ -828,7 +846,9 @@ class Update(BaseModel): """ id = models.UUIDField(primary_key=True, default=uuid4) - entity = models.ForeignKey("Entity", on_delete=models.CASCADE, related_name="updates") + entity = models.ForeignKey( + "Entity", on_delete=models.CASCADE, related_name="updates" + ) frequency = models.IntegerField() lag = models.IntegerField(blank=True, null=True) latest = models.DateTimeField(blank=True, null=True) @@ -882,7 +902,9 @@ def clean(self) -> None: ) if self.entity.category.slug != "datetime": - raise ValidationError("Entity's category is not in category.slug = `datetime`.") + raise ValidationError( + "Entity's category is not in category.slug = `datetime`." + ) return super().clean() @@ -894,7 +916,9 @@ class Table(BaseModel, OrderedModel): slug = models.SlugField(unique=False, max_length=255) name = models.CharField(max_length=255) description = models.TextField(blank=True, null=True) - dataset = models.ForeignKey("Dataset", on_delete=models.CASCADE, related_name="tables") + dataset = models.ForeignKey( + "Dataset", on_delete=models.CASCADE, related_name="tables" + ) version = models.IntegerField(null=True, blank=True) status = models.ForeignKey( "Status", on_delete=models.PROTECT, related_name="tables", null=True, blank=True @@ -949,7 +973,9 @@ class Table(BaseModel, OrderedModel): compressed_file_size = models.BigIntegerField(blank=True, null=True) number_rows = models.BigIntegerField(blank=True, null=True) number_columns = models.BigIntegerField(blank=True, null=True) - is_closed = models.BooleanField(default=False, help_text="Table is for BD Pro subscribers only") + is_closed = models.BooleanField( + default=False, help_text="Table is for BD Pro subscribers only" + ) page_views = models.BigIntegerField( default=0, help_text="Number of page views by Google Analytics", @@ -1262,7 +1288,10 @@ def clean(self) -> None: "observation_level" ] = "Observation level is not in the same table as the column." - if self.directory_primary_key and self.directory_primary_key.table.is_directory is False: + if ( + self.directory_primary_key + and self.directory_primary_key.table.is_directory is False + ): errors[ "directory_primary_key" ] = "Column indicated as a directory's primary key is not in a directory." @@ -1390,7 +1419,9 @@ class Dictionary(BaseModel): """Model definition for Dictionary.""" id = models.UUIDField(primary_key=True, default=uuid4) - column = models.ForeignKey("Column", on_delete=models.CASCADE, related_name="dictionaries") + column = models.ForeignKey( + "Column", on_delete=models.CASCADE, related_name="dictionaries" + ) graphql_nested_filter_fields_whitelist = ["id"] @@ -1409,7 +1440,9 @@ class CloudTable(BaseModel): """Model definition for CloudTable.""" id = models.UUIDField(primary_key=True, default=uuid4) - table = models.ForeignKey("Table", on_delete=models.CASCADE, related_name="cloud_tables") + table = models.ForeignKey( + "Table", on_delete=models.CASCADE, related_name="cloud_tables" + ) columns = models.ManyToManyField( "Column", related_name="cloud_tables", @@ -1439,7 +1472,9 @@ def clean(self) -> None: errors["gcp_table_id"] = "gcp_table_id must be in snake_case." for column in self.columns.all(): if column.table != self.table: - errors["columns"] = f"Column {column} does not belong to table {self.table}." + errors[ + "columns" + ] = f"Column {column} does not belong to table {self.table}." if errors: raise ValidationError(errors) @@ -1509,9 +1544,15 @@ class RawDataSource(BaseModel, OrderedModel): availability = models.ForeignKey( "Availability", on_delete=models.CASCADE, related_name="raw_data_sources" ) - languages = models.ManyToManyField("Language", related_name="raw_data_sources", blank=True) + languages = models.ManyToManyField( + "Language", related_name="raw_data_sources", blank=True + ) license = models.ForeignKey( - "License", on_delete=models.CASCADE, related_name="raw_data_sources", blank=True, null=True + "License", + on_delete=models.CASCADE, + related_name="raw_data_sources", + blank=True, + null=True, ) area_ip_address_required = models.ManyToManyField( "Area", related_name="raw_data_sources", blank=True @@ -1798,7 +1839,9 @@ def clean(self) -> None: self.end_second or 0, ) if start_datetime > end_datetime: - errors["start_year"] = ["Start datetime cannot be greater than end datetime"] + errors["start_year"] = [ + "Start datetime cannot be greater than end datetime" + ] except TypeError: errors["start_year"] = ["Start year or end year are invalid"] diff --git a/bd_api/apps/api/v1/tests/test_models.py b/bd_api/apps/api/v1/tests/test_models.py index 56515fb8..977afddc 100644 --- a/bd_api/apps/api/v1/tests/test_models.py +++ b/bd_api/apps/api/v1/tests/test_models.py @@ -110,7 +110,9 @@ def test_date_time_range_empty(coverage_tabela_open): @pytest.mark.django_db -def test_dataset_create(dataset_dados_mestres, tema_saude, tema_educacao, tag_aborto, tag_covid): +def test_dataset_create( + dataset_dados_mestres, tema_saude, tema_educacao, tag_aborto, tag_covid +): """Test for Dataset creation""" dataset_dados_mestres.save() dataset_dados_mestres.themes.add(tema_saude, tema_educacao) @@ -127,7 +129,9 @@ def test_table_create(tabela_bairros): @pytest.mark.django_db -def test_table_with_empty_coverage(tabela_bairros, coverage_tabela_open, datetime_range_empty): +def test_table_with_empty_coverage( + tabela_bairros, coverage_tabela_open, datetime_range_empty +): """ Test for Table with Coverage containing no DateTimeRange. Coverage must be empty string. @@ -200,7 +204,7 @@ def test_information_request_create( @pytest.mark.django_db -def test_analysis_create( # pylint: disable=too-many-arguments +def test_analysis_create( analise_bairros, dataset_dados_mestres, tema_saude, diff --git a/bd_api/conftest.py b/bd_api/conftest.py index aaac8805..0cfd5554 100644 --- a/bd_api/conftest.py +++ b/bd_api/conftest.py @@ -529,7 +529,9 @@ def fixture_coluna_state_id_bairros( @pytest.fixture(name="coluna_nome_bairros") @pytest.mark.django_db -def fixture_coluna_nome_bairros(tabela_bairros, bigquery_type_string, status_em_processamento): +def fixture_coluna_nome_bairros( + tabela_bairros, bigquery_type_string, status_em_processamento +): """Fixture for name column.""" return Column.objects.create( table=tabela_bairros, @@ -674,7 +676,7 @@ def fixture_chave_1(dicionario_1): @pytest.fixture(name="teste_qualidade") @pytest.mark.django_db -def fixture_teste_qualidade( # pylint: disable=too-many-arguments +def fixture_teste_qualidade( pipeline, analise_bairros, dataset_dados_mestres, diff --git a/poetry.lock b/poetry.lock index 1d9789ed..fe862abb 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.7.0 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand. [[package]] name = "aniso8601" @@ -53,55 +53,6 @@ files = [ {file = "async_timeout-4.0.3-py3-none-any.whl", hash = "sha256:7405140ff1230c310e51dc27b3145b9092d659ce68ff733fb0cefe3ee42be028"}, ] -[[package]] -name = "autoflake" -version = "2.2.1" -description = "Removes unused imports and unused variables" -optional = false -python-versions = ">=3.8" -files = [ - {file = "autoflake-2.2.1-py3-none-any.whl", hash = "sha256:265cde0a43c1f44ecfb4f30d95b0437796759d07be7706a2f70e4719234c0f79"}, - {file = "autoflake-2.2.1.tar.gz", hash = "sha256:62b7b6449a692c3c9b0c916919bbc21648da7281e8506bcf8d3f8280e431ebc1"}, -] - -[package.dependencies] -pyflakes = ">=3.0.0" -tomli = {version = ">=2.0.1", markers = "python_version < \"3.11\""} - -[[package]] -name = "black" -version = "22.12.0" -description = "The uncompromising code formatter." -optional = false -python-versions = ">=3.7" -files = [ - {file = "black-22.12.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9eedd20838bd5d75b80c9f5487dbcb06836a43833a37846cf1d8c1cc01cef59d"}, - {file = "black-22.12.0-cp310-cp310-win_amd64.whl", hash = "sha256:159a46a4947f73387b4d83e87ea006dbb2337eab6c879620a3ba52699b1f4351"}, - {file = "black-22.12.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d30b212bffeb1e252b31dd269dfae69dd17e06d92b87ad26e23890f3efea366f"}, - {file = "black-22.12.0-cp311-cp311-win_amd64.whl", hash = "sha256:7412e75863aa5c5411886804678b7d083c7c28421210180d67dfd8cf1221e1f4"}, - {file = "black-22.12.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c116eed0efb9ff870ded8b62fe9f28dd61ef6e9ddd28d83d7d264a38417dcee2"}, - {file = "black-22.12.0-cp37-cp37m-win_amd64.whl", hash = "sha256:1f58cbe16dfe8c12b7434e50ff889fa479072096d79f0a7f25e4ab8e94cd8350"}, - {file = "black-22.12.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:77d86c9f3db9b1bf6761244bc0b3572a546f5fe37917a044e02f3166d5aafa7d"}, - {file = "black-22.12.0-cp38-cp38-win_amd64.whl", hash = "sha256:82d9fe8fee3401e02e79767016b4907820a7dc28d70d137eb397b92ef3cc5bfc"}, - {file = "black-22.12.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:101c69b23df9b44247bd88e1d7e90154336ac4992502d4197bdac35dd7ee3320"}, - {file = "black-22.12.0-cp39-cp39-win_amd64.whl", hash = "sha256:559c7a1ba9a006226f09e4916060982fd27334ae1998e7a38b3f33a37f7a2148"}, - {file = "black-22.12.0-py3-none-any.whl", hash = "sha256:436cc9167dd28040ad90d3b404aec22cedf24a6e4d7de221bec2730ec0c97bcf"}, - {file = "black-22.12.0.tar.gz", hash = "sha256:229351e5a18ca30f447bf724d007f890f97e13af070bb6ad4c0a441cd7596a2f"}, -] - -[package.dependencies] -click = ">=8.0.0" -mypy-extensions = ">=0.4.3" -pathspec = ">=0.9.0" -platformdirs = ">=2" -tomli = {version = ">=1.1.0", markers = "python_full_version < \"3.11.0a7\""} - -[package.extras] -colorama = ["colorama (>=0.4.3)"] -d = ["aiohttp (>=3.7.4)"] -jupyter = ["ipython (>=7.8.0)", "tokenize-rt (>=3.2.0)"] -uvloop = ["uvloop (>=0.15.2)"] - [[package]] name = "cachetools" version = "5.3.1" @@ -234,20 +185,6 @@ files = [ {file = "charset_normalizer-3.3.0-py3-none-any.whl", hash = "sha256:e46cd37076971c1040fc8c41273a8b3e2c624ce4f2be3f5dfcb7a430c1d3acc2"}, ] -[[package]] -name = "click" -version = "8.1.7" -description = "Composable command line interface toolkit" -optional = false -python-versions = ">=3.7" -files = [ - {file = "click-8.1.7-py3-none-any.whl", hash = "sha256:ae74fb96c20a0277a1d615f1e4d73c8414f5a98db8b799a7931d1582f3390c28"}, - {file = "click-8.1.7.tar.gz", hash = "sha256:ca9853ad459e787e2192211578cc907e7594e294c7ccc834310722b41b9ca6de"}, -] - -[package.dependencies] -colorama = {version = "*", markers = "platform_system == \"Windows\""} - [[package]] name = "colorama" version = "0.4.6" @@ -549,22 +486,6 @@ docs = ["furo (>=2023.7.26)", "sphinx (>=7.1.2)", "sphinx-autodoc-typehints (>=1 testing = ["covdefaults (>=2.3)", "coverage (>=7.3)", "diff-cover (>=7.7)", "pytest (>=7.4)", "pytest-cov (>=4.1)", "pytest-mock (>=3.11.1)", "pytest-timeout (>=2.1)"] typing = ["typing-extensions (>=4.7.1)"] -[[package]] -name = "flake8" -version = "6.1.0" -description = "the modular source code checker: pep8 pyflakes and co" -optional = false -python-versions = ">=3.8.1" -files = [ - {file = "flake8-6.1.0-py2.py3-none-any.whl", hash = "sha256:ffdfce58ea94c6580c77888a86506937f9a1a227dfcd15f245d694ae20a6b6e5"}, - {file = "flake8-6.1.0.tar.gz", hash = "sha256:d5b3857f07c030bdb5bf41c7f53799571d75c4491748a3adcd47de929e34cd23"}, -] - -[package.dependencies] -mccabe = ">=0.7.0,<0.8.0" -pycodestyle = ">=2.11.0,<2.12.0" -pyflakes = ">=3.1.0,<3.2.0" - [[package]] name = "google-api-core" version = "2.12.0" @@ -1137,23 +1058,6 @@ files = [ {file = "iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3"}, ] -[[package]] -name = "isort" -version = "5.12.0" -description = "A Python utility / library to sort Python imports." -optional = false -python-versions = ">=3.8.0" -files = [ - {file = "isort-5.12.0-py3-none-any.whl", hash = "sha256:f84c2818376e66cf843d497486ea8fed8700b340f308f076c6fb1229dff318b6"}, - {file = "isort-5.12.0.tar.gz", hash = "sha256:8bef7dde241278824a6d83f44a544709b065191b95b6e50894bdc722fcba0504"}, -] - -[package.extras] -colors = ["colorama (>=0.4.3)"] -pipfile-deprecated-finder = ["pip-shims (>=0.5.2)", "pipreqs", "requirementslib"] -plugins = ["setuptools"] -requirements-deprecated-finder = ["pip-api", "pipreqs"] - [[package]] name = "loguru" version = "0.7.2" @@ -1172,28 +1076,6 @@ win32-setctime = {version = ">=1.0.0", markers = "sys_platform == \"win32\""} [package.extras] dev = ["Sphinx (==7.2.5)", "colorama (==0.4.5)", "colorama (==0.4.6)", "exceptiongroup (==1.1.3)", "freezegun (==1.1.0)", "freezegun (==1.2.2)", "mypy (==v0.910)", "mypy (==v0.971)", "mypy (==v1.4.1)", "mypy (==v1.5.1)", "pre-commit (==3.4.0)", "pytest (==6.1.2)", "pytest (==7.4.0)", "pytest-cov (==2.12.1)", "pytest-cov (==4.1.0)", "pytest-mypy-plugins (==1.9.3)", "pytest-mypy-plugins (==3.0.0)", "sphinx-autobuild (==2021.3.14)", "sphinx-rtd-theme (==1.3.0)", "tox (==3.27.1)", "tox (==4.11.0)"] -[[package]] -name = "mccabe" -version = "0.7.0" -description = "McCabe checker, plugin for flake8" -optional = false -python-versions = ">=3.6" -files = [ - {file = "mccabe-0.7.0-py2.py3-none-any.whl", hash = "sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e"}, - {file = "mccabe-0.7.0.tar.gz", hash = "sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325"}, -] - -[[package]] -name = "mypy-extensions" -version = "1.0.0" -description = "Type system extensions for programs checked with the mypy type checker." -optional = false -python-versions = ">=3.5" -files = [ - {file = "mypy_extensions-1.0.0-py3-none-any.whl", hash = "sha256:4392f6c0eb8a5668a69e23d168ffa70f0be9ccfd32b5cc2d26a34ae5b844552d"}, - {file = "mypy_extensions-1.0.0.tar.gz", hash = "sha256:75dbf8955dc00442a438fc4d0666508a9a97b6bd41aa2f0ffe9d2f2725af0782"}, -] - [[package]] name = "nodeenv" version = "1.8.0" @@ -1711,17 +1593,6 @@ files = [ [package.dependencies] pyasn1 = ">=0.4.6,<0.6.0" -[[package]] -name = "pycodestyle" -version = "2.11.0" -description = "Python style guide checker" -optional = false -python-versions = ">=3.8" -files = [ - {file = "pycodestyle-2.11.0-py2.py3-none-any.whl", hash = "sha256:5d1013ba8dc7895b548be5afb05740ca82454fd899971563d2ef625d090326f8"}, - {file = "pycodestyle-2.11.0.tar.gz", hash = "sha256:259bcc17857d8a8b3b4a2327324b79e5f020a13c16074670f9c8c8f872ea76d0"}, -] - [[package]] name = "pydantic" version = "2.5.3" @@ -1874,31 +1745,6 @@ google-auth = {version = ">=1.25.0,<3.0dev", markers = "python_version >= \"3.6\ google-auth-oauthlib = {version = ">=0.4.0", markers = "python_version >= \"3.6\""} setuptools = "*" -[[package]] -name = "pyflakes" -version = "3.1.0" -description = "passive checker of Python programs" -optional = false -python-versions = ">=3.8" -files = [ - {file = "pyflakes-3.1.0-py2.py3-none-any.whl", hash = "sha256:4132f6d49cb4dae6819e5379898f2b8cce3c5f23994194c24b77d5da2e36f774"}, - {file = "pyflakes-3.1.0.tar.gz", hash = "sha256:a0aae034c444db0071aa077972ba4768d40c830d9539fd45bf4cd3f8f6992efc"}, -] - -[[package]] -name = "pygments" -version = "2.16.1" -description = "Pygments is a syntax highlighting package written in Python." -optional = false -python-versions = ">=3.7" -files = [ - {file = "Pygments-2.16.1-py3-none-any.whl", hash = "sha256:13fc09fa63bc8d8671a6d247e1eb303c4b343eaee81d861f3404db2935653692"}, - {file = "Pygments-2.16.1.tar.gz", hash = "sha256:1daff0494820c69bc8941e407aa20f577374ee88364ee10a98fdbe0aece96e29"}, -] - -[package.extras] -plugins = ["importlib-metadata"] - [[package]] name = "pyjwt" version = "2.8.0" @@ -2020,6 +1866,7 @@ files = [ {file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"}, + {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a08c6f0fe150303c1c6b71ebcd7213c2858041a7e01975da3a99aed1e7a378ef"}, {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"}, {file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"}, {file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"}, @@ -2125,6 +1972,32 @@ files = [ [package.dependencies] pyasn1 = ">=0.1.3" +[[package]] +name = "ruff" +version = "0.2.0" +description = "An extremely fast Python linter and code formatter, written in Rust." +optional = false +python-versions = ">=3.7" +files = [ + {file = "ruff-0.2.0-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:638ea3294f800d18bae84a492cb5a245c8d29c90d19a91d8e338937a4c27fca0"}, + {file = "ruff-0.2.0-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:3ff35433fcf4dff6d610738712152df6b7d92351a1bde8e00bd405b08b3d5759"}, + {file = "ruff-0.2.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:bf9faafbdcf4f53917019f2c230766da437d4fd5caecd12ddb68bb6a17d74399"}, + {file = "ruff-0.2.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:8153a3e4128ed770871c47545f1ae7b055023e0c222ff72a759f5a341ee06483"}, + {file = "ruff-0.2.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:e8a75a98ae989a27090e9c51f763990ad5bbc92d20626d54e9701c7fe597f399"}, + {file = "ruff-0.2.0-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:87057dd2fdde297130ff99553be8549ca38a2965871462a97394c22ed2dfc19d"}, + {file = "ruff-0.2.0-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:6d232f99d3ab00094ebaf88e0fb7a8ccacaa54cc7fa3b8993d9627a11e6aed7a"}, + {file = "ruff-0.2.0-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:3d3c641f95f435fc6754b05591774a17df41648f0daf3de0d75ad3d9f099ab92"}, + {file = "ruff-0.2.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3826fb34c144ef1e171b323ed6ae9146ab76d109960addca730756dc19dc7b22"}, + {file = "ruff-0.2.0-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:eceab7d85d09321b4de18b62d38710cf296cb49e98979960a59c6b9307c18cfe"}, + {file = "ruff-0.2.0-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:30ad74687e1f4a9ff8e513b20b82ccadb6bd796fe5697f1e417189c5cde6be3e"}, + {file = "ruff-0.2.0-py3-none-musllinux_1_2_i686.whl", hash = "sha256:a7e3818698f8460bd0f8d4322bbe99db8327e9bc2c93c789d3159f5b335f47da"}, + {file = "ruff-0.2.0-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:edf23041242c48b0d8295214783ef543847ef29e8226d9f69bf96592dba82a83"}, + {file = "ruff-0.2.0-py3-none-win32.whl", hash = "sha256:e155147199c2714ff52385b760fe242bb99ea64b240a9ffbd6a5918eb1268843"}, + {file = "ruff-0.2.0-py3-none-win_amd64.whl", hash = "sha256:ba918e01cdd21e81b07555564f40d307b0caafa9a7a65742e98ff244f5035c59"}, + {file = "ruff-0.2.0-py3-none-win_arm64.whl", hash = "sha256:3fbaff1ba9564a2c5943f8f38bc221f04bac687cc7485e45237579fee7ccda79"}, + {file = "ruff-0.2.0.tar.gz", hash = "sha256:63856b91837606c673537d2889989733d7dffde553828d3b0f0bacfa6def54be"}, +] + [[package]] name = "setuptools" version = "68.2.2" @@ -2308,4 +2181,4 @@ dev = ["doc8", "flake8", "flake8-import-order", "rstcheck[sphinx]", "sphinx"] [metadata] lock-version = "2.0" python-versions = ">=3.10,<3.13" -content-hash = "94b51293180197812b3e40eb13ffcf1734b9a0db8f439f136477a37a90d99035" +content-hash = "e0110d9fb4eb63c58f31185e5917ef78ca5a5293b36f597be51baba70d7dbe1b" diff --git a/pyproject.toml b/pyproject.toml index af01ba49..a17d016f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,13 +40,9 @@ dj-stripe = "^2.8.3" pydantic = "^2.5.3" [tool.poetry.group.dev.dependencies] -black = "^22.3.0" -flake8 = "^6.1.0" -pygments = "^2.15.1" yamllint = "^1.32.0" -autoflake = "^2.2.0" -isort = "^5.12.0" pre-commit = "^3.3.3" +ruff = "^0.2.0" [tool.poetry.group.test.dependencies] pytest = "^7.2.1" @@ -56,17 +52,6 @@ pytest-django = "^4.5.2" lint = "scripts.lint:main" test = "scripts.test:main" -[tool.black] -line-length = 100 -target-version = ["py310"] - -[tool.isort] -profile = "black" -line_length = 100 -multi_line_output = 3 -use_parentheses = true -include_trailing_comma = true - [build-system] requires = ["poetry-core>=1.0.0"] build-backend = "poetry.core.masonry.api" diff --git a/scripts/lint.py b/scripts/lint.py index 0b947e7e..0b3e6549 100644 --- a/scripts/lint.py +++ b/scripts/lint.py @@ -10,10 +10,8 @@ def run(*args): def main(): """Lint all python files in the project""" code = 0 - code |= run(["poetry", "check"]) code |= run(["yamllint", "."]) - code |= run(["black", "--check", "."]) - code |= run(["isort", "--check-only", "."]) - code |= run(["autoflake", "--check", "--recursive", "--quiet", "."]) - code |= run(["flake8", "."]) + code |= run(["poetry", "check"]) + code |= run(["ruff", "check", "."]) + code |= run(["ruff", "format", "."]) exit(code)