Skip to content

pre-commit: update black, black-docs version #660

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

gastmaier
Copy link
Contributor

@gastmaier gastmaier commented Apr 10, 2025

Description

typed-ast is not maintained anymore, and builds with newer python versions raise:

  ast27/Custom/../Include/compile.h:12:12: error: unknown type name ‘PyFutureFeatures’
     12 | PyAPI_FUNC(PyFutureFeatures *) PyFuture_FromAST(struct _mod *, const char *);

The minimum black version with 966baaais 21.4b0,
but due to black-docs min version with the same fix (a24ed2d, 1.13.0), set as 22.12.0.

Ready for review if ci passes, don't know if between 19.10b0->22.12.0 there are breaking changes that affects the intended pre-commit hooks behavior.

From CI run
https://github.com/analogdevicesinc/pyadi-iio/actions/runs/14374856506/job/40304790945?pr=660
seems to install with all py versions, but touches all many files.

ex diff (pretty-much running on all files instead of touched files. due to pre-commit run --all-files 2> /dev/null, is this intended behavior?
Maybe git diff --name-only $base_sha..$head_sha | xargs pre-commit run --files is more suitable, base_sha, head_sha setup suggestion, or strictier pre-commit run --from-ref $base_ref --to-ref $head_sha)

diff --git a/adi/ad777x.py b/adi/ad777x.py
index ae2949c3..db53efe0 100644
--- a/adi/ad777x.py
+++ b/adi/ad777x.py
@@ -14,7 +14,7 @@ from adi.rx_tx import rx

 class ad777x(rx, context_manager):

-    """ AD777x ADC """
+    """AD777x ADC"""

     _complex_data = False
     channel = []  # type: ignore
@@ -58,7 +58,7 @@ class ad777x(rx, context_manager):

     class _channel(attribute):

-        """ AD777x channel """
+        """AD777x channel"""

         def __init__(self, ctrl, channel_name):
             self.name = channel_name
diff --git a/adi/ad7799.py b/adi/ad7799.py
index 0fd992c2..282a13b3 100644
--- a/adi/ad7799.py
+++ b/adi/ad7799.py
@@ -8,7 +8,7 @@ from adi.rx_tx import rx


 class ad7799(rx, context_manager):
-    """ AD7799 ADC """
+    """AD7799 ADC"""

     _complex_data = False
     channel = []  # type: ignore
diff --git a/adi/ad9081_mc.py b/adi/ad9081_mc.py
index 7fd53524..593ef468 100644
--- a/adi/ad9081_mc.py
+++ b/adi/ad9081_mc.py
@@ -168,7 +168,7 @@ class ad9081_mc(ad9081):
         # Bring up DMA and DDS interfaces
         rx_tx.__init__(self)
         sync_start.__init__(self)
-        self.rx_buffer_size = 2 ** 16
+        self.rx_buffer_size = 2**16

     def _map_unique(self, paths):
         self._rx_fine_ddc_channel_names = {}
@@ -232,7 +232,11 @@ class ad9081_mc(ad9081):
     def _get_iio_attr_vec(self, channel_names_dict, attr, output):
         return {
             dev: ad9081._get_iio_attr_vec(
-                self, channel_names_dict[dev], attr, output, self._ctx.find_device(dev),
+                self,
+                channel_names_dict[dev],
+                attr,
+                output,
+                self._ctx.find_device(dev),
             )
             for dev in channel_names_dict
         }

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How has this been tested?

repo=/mnt/wsl/data/repos/pyadi-iio
podman run -it --replace --entrypoint= --name=python-3.13 --workdir=$repo --volume $repo:$repo --user root python:3.13 bash -l
pip install pre-commit
pre-commit

Test Configuration:

  • Hardware:
  • OS:

Documentation

If this is a new feature or example please mention or link any documentation. All new hardware interface classes require documentation.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have signed off all commits and they contain "Signed-off by: "
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

typed-ast is not maintained anymore, and builds with newer python
versions raises:

  ast27/Custom/../Include/compile.h:12:12: error: unknown type name ‘PyFutureFeatures’
     12 | PyAPI_FUNC(PyFutureFeatures *) PyFuture_FromAST(struct _mod *, const char *);

The minimum black version with 966baaa is 21.4b0,
but due to black-docs min version with the same fix (a24ed2d, 1.13.0),
set as 22.12.0.

Signed-off-by: Jorge Marques <[email protected]>
Copy link

github-actions bot commented Apr 10, 2025

Test Results

1 676 tests  ±0     442 ✅ ±0   12m 1s ⏱️ -1s
    1 suites ±0   1 232 💤 ±0 
    1 files   ±0       2 ❌ ±0 

For more details on these failures, see this check.

Results for commit 820b015. ± Comparison against base commit 147403f.

This pull request removes 4 and adds 4 tests. Note that renamed tests count towards both.
test.test_adrv9002_p ‑ test_adrv9002_hardware_gain[attr=rx_hardwaregain_chan0-val=[10.5, 17.5, 19.0, 23.0, 4.5, 3.5, 10.5, 9.5, 33.5, 33.5]-depends={'gain_control_mode_chan1': 'spi', 'rx_ensm_mode_chan1': 'rf_enabled'}-classname=adi.adrv9002]
test.test_adrv9002_p ‑ test_adrv9002_hardware_gain[attr=rx_hardwaregain_chan0-val=[19.5, 4.5, 14.0, 30.0, 2.0, 19.5, 7.5, 30.0, 6.5, 31.0]-depends={'gain_control_mode_chan0': 'spi', 'rx_ensm_mode_chan0': 'rf_enabled'}-classname=adi.adrv9002]
test.test_adrv9002_p ‑ test_adrv9002_hardware_gain[attr=tx_hardwaregain_chan0-val=[-21.35, -13.15, -18.1, -17.6, -9.95, -28.9, -31.1, -3.5, -14.85, -35.95]-depends={'atten_control_mode_chan0': 'spi'}-classname=adi.adrv9002]
test.test_adrv9002_p ‑ test_adrv9002_hardware_gain[attr=tx_hardwaregain_chan1-val=[-30.05, -27.15, -36.0, -0.8, -29.95, -29.6, -22.15, -13.2, -6.65, -20.15]-depends={'atten_control_mode_chan1': 'spi'}-classname=adi.adrv9002]
test.test_adrv9002_p ‑ test_adrv9002_hardware_gain[attr=rx_hardwaregain_chan0-val=[18.5, 31.5, 13.5, 8.0, 11.0, 15.5, 23.5, 33.0, 26.5, 9.0]-depends={'gain_control_mode_chan1': 'spi', 'rx_ensm_mode_chan1': 'rf_enabled'}-classname=adi.adrv9002]
test.test_adrv9002_p ‑ test_adrv9002_hardware_gain[attr=rx_hardwaregain_chan0-val=[28.0, 0.5, 10.0, 2.0, 34.0, 16.5, 20.0, 31.5, 29.0, 8.0]-depends={'gain_control_mode_chan0': 'spi', 'rx_ensm_mode_chan0': 'rf_enabled'}-classname=adi.adrv9002]
test.test_adrv9002_p ‑ test_adrv9002_hardware_gain[attr=tx_hardwaregain_chan0-val=[-6.15, -37.45, -37.2, -20.35, -12.4, -0.7, -10.2, -17.85, -39.05, -1.45]-depends={'atten_control_mode_chan0': 'spi'}-classname=adi.adrv9002]
test.test_adrv9002_p ‑ test_adrv9002_hardware_gain[attr=tx_hardwaregain_chan1-val=[-7.55, -22.15, -18.15, -23.6, -4.65, -16.5, -25.75, -18.6, -5.95, -15.15]-depends={'atten_control_mode_chan1': 'spi'}-classname=adi.adrv9002]

♻️ This comment has been updated with latest results.

@gastmaier gastmaier marked this pull request as ready for review April 10, 2025 07:57
@tfcollins
Copy link
Collaborator

Yeah newer black versions change the default style so when we update everything is gunna get touched. Might switch to ruff over black for speed reasons as well. Ideally we can get repo level changes into 1 commit so git blame and related can filter more easily

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants