Skip to content

Move import to I2C only section #7

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

Closed
wants to merge 6 commits into from
Closed

Move import to I2C only section #7

wants to merge 6 commits into from

Conversation

dglaude
Copy link
Contributor

@dglaude dglaude commented Jul 25, 2020

Move the import (next pylint will have to ignore this

dglaude added 2 commits July 25, 2020 19:59
Move the import (next pylint will have to ignore this
@dglaude dglaude changed the title Update adafruit_pm25.py Move import to I2C only section Jul 25, 2020
This seems to work as far as I can test... but it is supposed to be not recommended.
And next I need to fight pylint...
dglaude added 3 commits July 25, 2020 23:27
This keep pylint happy.
This is Black recommendation... not sure I like it.
@tannewt
Copy link
Member

tannewt commented Jul 27, 2020

Why do this? If for memory saving, I'd prefer to move this library to a package with separate modules (aka files) for i2c and uart.

@dglaude
Copy link
Contributor Author

dglaude commented Aug 3, 2020

I did this because of issue #5 and I got multiple suggestions on how to do it. So I gave this a try.

I am happy with "not fixing this", I would have learn to fight against Pylint and Black when they do not aggree.
I am also happy with "fixing another way", as you describe... but I have never done multi-files library.

Also there is a bit of OO Python here, with a "super class" that use the I2C or UART for implementation detail, and I don't know how that work accross separated files.

@tannewt
Copy link
Member

tannewt commented Aug 3, 2020

I did this because of issue #5 and I got multiple suggestions on how to do it. So I gave this a try.

I am happy with "not fixing this", I would have learn to fight against Pylint and Black when they do not agree.
I am also happy with "fixing another way", as you describe... but I have never done multi-files library.

Up to you if you want to continue. Below I've outlined the steps.

Also there is a bit of OO Python here, with a "super class" that use the I2C or UART for implementation detail, and I don't know how that work accross separated files.

  1. Make an adafruit_pm25 directory.
  2. Move adafruit_pm25.py to adafruit_pm25/__init__.py
  3. Move the i2c version into a new adafruit_pm25/i2c.py file and at the top from . import PM25 to import from __init__.py. You can then import I2CDevice here too.
  4. Repeat for UART.
  5. Update the examples to from adafruit_pm25.i2c import PM25_I2C

@dglaude
Copy link
Contributor Author

dglaude commented Aug 10, 2020

I also have #6 pending. When that is fix, I can try to split I2C from UART in separate files... But I don't want to make two incompatible PR.

@tannewt
Copy link
Member

tannewt commented Aug 10, 2020

Ok, I merged #6. Sorry for the delay.

@kattni
Copy link
Contributor

kattni commented Aug 19, 2020

I'm closing this in favor of #8.

@kattni kattni closed this Aug 19, 2020
@dglaude dglaude deleted the patch-3 branch August 19, 2020 20:00
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.

3 participants