CLN: Made final changes to /pandas/tests/scalar
State: closed


Labels:
name: Clean

Comments:
If I understand correctly the idea of https://github.com/pandas-dev/pandas/issues/35925 is to remove commas at the ends of single lines, not trailing commas generally

cc @MarcoGorelli 
> 
> 
> If I understand correctly the idea of #35925 is to remove commas at the ends of single lines, not trailing commas generally
> 
> cc @MarcoGorelli

Yes, I believe that the magic comma in the end of the multiline statements does not lead to any rearrangement in black. In the single line, however, the situation is different.

https://github.com/psf/black/blob/master/docs/the_black_code_style.md#the-magic-trailing-comma

So, in the case of removing a trailing comma from multiline statements, black would in contrast try to squeeze them into the single line.

Workflow here should be:

- upgrade black
- try running black on files
- for lines that have changed, try removing trailing commas
- run black again
- downgrade black to current version
- run black again to check it doesn't modify anything
I tried removing the trailing commas present in the test_arithmetic.py file. But running the file throws the below error 

**No name 'offsets' in module 'pandas._libs.tslibs'**

Is this something that I should modify?
> 
> 
> I tried removing the trailing commas present in the test_arithmetic.py file. But running the file throws the below error
> 
> **No name 'offsets' in module 'pandas._libs.tslibs'**
> 
> Is this something that I should modify?

Maybe you want to locally re-build C extensions.

```
python setup.py build_ext --inplace -j 4
```

https://pandas.pydata.org/pandas-docs/stable/development/contributing.html#creating-a-python-environment-pip
> > I tried removing the trailing commas present in the test_arithmetic.py file. But running the file throws the below error
> > **No name 'offsets' in module 'pandas._libs.tslibs'**
> > Is this something that I should modify?
> 
> Maybe you want to locally re-build C extensions.
> 
> ```
> python setup.py build_ext --inplace -j 4
> ```
> 
> https://pandas.pydata.org/pandas-docs/stable/development/contributing.html#creating-a-python-environment-pip

The error still persists even after performing a local rebuild of C extensions. Also I tried finding out where exactly the linting check had failed in the CI Checks option, but din't find what the linting error was. So could you guide me on that?
> 
> 
> > > I tried removing the trailing commas present in the test_arithmetic.py file. But running the file throws the below error
> > > **No name 'offsets' in module 'pandas._libs.tslibs'**
> > > Is this something that I should modify?
> > 
> > 
> > Maybe you want to locally re-build C extensions.
> > ```
> > python setup.py build_ext --inplace -j 4
> > ```
> > 
> > 
> > https://pandas.pydata.org/pandas-docs/stable/development/contributing.html#creating-a-python-environment-pip
> 
> The error still persists even after performing a local rebuild of C extensions. Also I tried finding out where exactly the linting check had failed in the CI Checks option, but din't find what the linting error was. So could you guide me on that?

Apparently, black reformatted files.

```
black --version
black, version 19.10b0
Checking black formatting
would reformat /home/runner/work/pandas/pandas/pandas/tests/scalar/test_na_scalar.py
would reformat /home/runner/work/pandas/pandas/pandas/tests/scalar/timestamp/test_arithmetic.py
would reformat /home/runner/work/pandas/pandas/pandas/tests/scalar/timestamp/test_constructors.py
Oh no! 💥 💔 💥
3 files would be reformatted, 1130 files would be left unchanged.
```

Please try to follow the approach by @MarcoGorelli.
> But running the file throws the below error

You don't need to run the file, you just need to run `black` on the file
Thanks @Abishek15592 for the PR. #35925 has been now been closed off by #36493 so closing.